Skip to content

Commit

Permalink
测试triton可用性
Browse files Browse the repository at this point in the history
  • Loading branch information
Puiching-Memory committed Nov 22, 2024
1 parent f0899a6 commit 4b5600c
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 21 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format",
"tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping"
]
],
"files.associations": {
"atomic": "cpp",
"algorithm": "cpp"
}
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ conda create -n monolite python=3.12

### 前置组件

| 系统 | 前置组件 | 下载URL | 备注 |
| ------- | ------------------ | --------------------------------------------------------------------------------------------------- | -------------------- |
| windows | Visual Studio 2022 | [download](https://visualstudio.microsoft.com/zh-hans/vs/) | 注意不同版本间的冲突 |
| windows | Cmake | [download](https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-windows-x86_64.msi) | 3.30.5 |
| windows | MSbuild | 通过VS2022下载 | |
| windows | MSVC | 通过VS2022下载 | |
| 系统 | 组件 | 下载URL | 备注 |
| ------- | ------------------ | --------------------------------------------------------------------------------------------------- | ---------------------- |
| windows | Visual Studio 2022 | [download](https://visualstudio.microsoft.com/zh-hans/vs/) | 注意不同版本间的冲突 |
| windows | Cmake | [download](https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-windows-x86_64.msi) | 3.30.5 |
| windows | MSbuild | 通过VS2022下载 | |
| windows | MSVC | 通过VS2022下载 | 手动添加至环境变量PATH |

### pip

Expand Down
35 changes: 35 additions & 0 deletions docs/zh/triton_windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 头文件


```
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
```


复制到

```
C:\Users\11386\.conda\envs\monolite\Lib\site-packages\torch\include
```



# LIB


```
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\lib\onecore\x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64
```


复制到

```
C:\Users\11386\.conda\envs\monolite\Lib\site-packages\torch\lib
```
2 changes: 1 addition & 1 deletion lib/datasets/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def apply_to_bboxes(
A.HorizontalFlip(p=0.5),
A.RandomBrightnessContrast(p=0.2),
# A.TemplateTransform(),
AugTest(p=0.5),
AugTest(p=0.2),
]
)

Expand Down
2 changes: 1 addition & 1 deletion lib/datasets/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __getitem__(self, index):
heatmap, (int(1280 / 8), int(384 / 8)), interpolation=cv2.INTER_AREA
) # 缩放至heatmap大小
heatmap = np.expand_dims(heatmap, axis=0) # 增加维度

heatmap_backgroud = np.ones_like(heatmap) # heatmap背景
heatmap_backgroud = heatmap_backgroud - heatmap

Expand Down
60 changes: 58 additions & 2 deletions lib/datasets/kitti_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
import cv2
from typing import Union, Optional

METAINFO = {
"classes": (
"Pedestrian",
"Cyclist",
"Car",
"Van",
"Truck",
"Person_sitting",
"Tram",
"Misc",
),
"palette": [
(106, 0, 228),
(119, 11, 32),
(165, 42, 42),
(0, 0, 192),
(197, 226, 255),
(0, 60, 100),
(0, 0, 142),
(255, 77, 255),
],
}

################ Object3D ##################


Expand Down Expand Up @@ -33,7 +56,7 @@ def __init__(self, line: str):
)
self.dis_to_cam = np.linalg.norm(self.pos)
self.ry = float(label[14])
self.score = float(label[15]) if label.__len__() == 16 else -1.0
self.score = float(label[15]) if len(label) == 16 else -1.0
self.level_str = None
self.level = self.get_obj_level()

Expand Down Expand Up @@ -163,6 +186,39 @@ def get_calib_from_file(calib_file):


class Calibration(object):
"""kitti calibration class
Args:
calib (Union[str, dict]): calibration file path or calibration dict
3d XYZ in <label>.txt are in rect camera coord.
2d box xy are in image2 coord
Points in <lidar>.bin are in Velodyne coord.
y_image2 = P^2_rect * x_rect
y_image2 = P^2_rect * R0_rect * Tr_velo_to_cam * x_velo
x_ref = Tr_velo_to_cam * x_velo
x_rect = R0_rect * x_ref
P^2_rect = [f^2_u, 0, c^2_u, -f^2_u b^2_x;
0, f^2_v, c^2_v, -f^2_v b^2_y;
0, 0, 1, 0]
= K * [1|t]
image2 coord:
----> x-axis (u)
|
|
v y-axis (v)
velodyne coord:
front x, left y, up z
rect/ref camera coord:
right x, down y, front z
Ref (KITTI paper): http://www.cvlibs.net/publications/Geiger2013IJRR.pdf
"""

def __init__(self, calib: Union[str, dict]):

if isinstance(calib, str):
Expand All @@ -184,7 +240,7 @@ def __init__(self, calib: Union[str, dict]):
self.tx = self.P2[0, 3] / (-self.fu)
self.ty = self.P2[1, 3] / (-self.fv)

def cart_to_hom(self, pts):
def cart_to_hom(self, pts: np.ndarray) -> np.ndarray:
"""
:param pts: (N, 3 or 2)
:return pts_hom: (N, 4 or 3)
Expand Down
31 changes: 21 additions & 10 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
pcontext = psutil.Process(pid)
# os.environ["CUDA_LAUNCH_BLOCKING"] = "1" # 设置同步cuda,仅debug时使用
# os.environ["TORCH_LOGS"] = "+dynamo"
# os.environ["TORCHDYNAMO_VERBOSE"] = "1"
# os.environ["TORCHDYNAMO_VERBOSE"] = "1"
print(sys.path)

def train(
model: torch.nn.Module,
Expand Down Expand Up @@ -198,8 +199,10 @@ def train(
completed=epoch_now + 1,
total=trainner.get_end_epoch(),
)

logger.info(f"epoch {epoch_now+1} finished, time: {time.time()-epoch_start_time:.2f}s")

logger.info(
f"epoch {epoch_now+1} finished, time: {time.time()-epoch_start_time:.2f}s"
)

if ema_model is not None:
logger.info("update bn with ema model, it may takes few minutes ...")
Expand All @@ -226,13 +229,21 @@ def train(
args = parser.parse_args()

# 初始化swanlab,启动$swanlab watch ./logs
swanlab.init(
project="monolite",
experiment_name=f"{os.path.basename(args.cfg)}_{datetime.datetime.now().strftime('%Y/%m/%d_%H:%M:%S')}",
# logdir="./logs", # 本地模式
# mode="local",
)

try:
swanlab.init(
project="monolite",
experiment_name=f"{os.path.basename(args.cfg)}_{datetime.datetime.now().strftime('%Y/%m/%d_%H:%M:%S')}",
# logdir="./logs", # 本地模式
# mode="local",
)
except Exception as e:
logger.error(f"{e}\nInit swanlab in local mode")
swanlab.init(
project="monolite",
experiment_name=f"{os.path.basename(args.cfg)}_{datetime.datetime.now().strftime('%Y/%m/%d_%H:%M:%S')}",
logdir="./logs", # 本地模式
mode="local",
)
# 添加模块搜索路径
sys.path.append(args.cfg)

Expand Down

0 comments on commit 4b5600c

Please sign in to comment.