2023-10-17-今日內容

# 2023-10-17-traffic light detection dataset

2023-10-17-tqdm

2023-10-17-multiple gpu handling

🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️下一個筆記🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️

2023-10-17-traffic light detection dataset


layout: post title: ‘traffic light detection dataset ‘ date: 2023-10-17T03:09:00-04:00


https://universe.roboflow.com/signal-sense-traffic-signal-detection/traffic-signals- mcmpm/dataset/16

https://universe.roboflow.com/fyp-wrdsh/road-signs-and-traffic-lights-dataset/browse?queryText=&pageSize=50&startingIndex=0&browseQuery=true

#trafficlight

🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️下一個筆記🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️

2023-10-17-tqdm


  1. 使用tqdm库: 如果想要一个更美观的进度条,可以使用tqdm库。首先,你需要安装tqdm: bash

Copy code pip install tqdm 然后可以这样使用它: python

Copy code from tqdm import tqdm

def batch_process(video_folder, output_video_folder, output_csv_folder): os.makedirs(output_video_folder, exist_ok=True) os.makedirs(output_csv_folder, exist_ok=True)

for video_file in tqdm(os.listdir(video_folder)):
    # ... 其他代码 ... tqdm会为os.listdir(video_folder)循环创建一个可视化的进度条,显示你的代码处理进度。 #tqdm #批量處理

🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️下一個筆記🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️🐿️

2023-10-17-multiple gpu handling


layout: post title: ‘multiple gpu handling ‘ date: 2023-10-17T01:29:37-04:00


import torch

torch.cuda.set_device(0) # 对于code1.py

或者

torch.cuda.set_device(1) # 对于code2.py

在Windows环境下,你可以使用一个批处理文件(.bat)来达到类似的目的。以下是步骤:

  1. 使用文本编辑器(如Notepad或VS Code)创建一个新文件。
  2. 将以下代码复制并粘贴到该文件中:
     SET CUDA_VISIBLE_DEVICES=0
     start python code1.py
    
     SET CUDA_VISIBLE_DEVICES=1
     start python code2.py
    
  3. 保存文件为run_scripts.bat(确保文件扩展名为.bat)。
  4. 双击run_scripts.bat文件,或在命令提示符中导航到该文件的目录并运行run_scripts.bat

start命令将使每个Python脚本在其自己的新窗口中运行。SET CUDA_VISIBLE_DEVICES命令是用来指定每个脚本应该使用哪个GPU。

请注意,这种方法的一个限制是,SET CUDA_VISIBLE_DEVICES可能不会像在Linux下那样工作,因为它是为Unix-like系统设计的。在Windows中,你可能需要使用其他方法来指定GPU设备,例如在Python代码中使用PyTorch的torch.cuda.set_device()函数。

如果你的代码确实基于PyTorch,你可以在code1.pycode2.py中分别添加以下行来指定要使用的GPU:

import torch

torch.cuda.set_device(0)  # 对于code1.py

# 或者

torch.cuda.set_device(1)  # 对于code2.py

在这种情况下,你的run_scripts.bat文件只需包含以下行:

start python code1.py
start python code2.py

#multiplegpu #torch #windowsbatch #匯總今日內容