有关python环境的一些指南

> PyTorch <

[TOC]

创建虚拟环境

1
conda create -n ${environment_name}

激活虚拟环境

1
2
conda activate ${environment_name}
# conda deactivate ${environment_name}

选择python版本

1
conda install python=${python_version}

安装cuda

> official website <

1
2
3
conda install cudatoolkit==${cuda_version} -c nvidia
conda install cuda -c nvidia/label/cuda-${cuda_version}
conda install nvidia::cuda-nvcc # an alternative way

安装PyTorch

> PyTorch <

This transaction has incompatible packages due to a shared path.

1
conda clean --all

安装torch-scatter

1
conda install pytorch-scatter -c pyg

查询cuda memory

1
nvidia-smi --query-gpu=memory.total,memory.used --format=csv

检查当前GPU内存占用情况

1
nvidia-smi --query-compute-apps=pid,name,gpu_bus_id,used_memory --format=csv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ nvidia-smi --help-query-compute-apps

List of valid properties to query for the switch "--query-compute-apps":

Section about Active Compute Processes properties
List of processes having compute context on the device.

"timestamp"
The timestamp of when the query was made in format "YYYY/MM/DD HH:MM:SS.msec".

"gpu_name"
The official product name of the GPU. This is an alphanumeric string. For all products.

"gpu_bus_id"
PCI bus id as "domain:bus:device.function", in hex.

"gpu_serial"
This number matches the serial number physically printed on each board. It is a globally unique immutable alphanumeric value.

"gpu_uuid"
This value is the globally unique immutable alphanumeric identifier of the GPU. It does not correspond to any physical label on the board.

"pid"
Process ID of the compute application

"process_name" or "name"
Process Name

"used_gpu_memory" or "used_memory"
Amount memory used on the device by the context. Not available on Windows when running in WDDM mode because Windows KMD manages all the memory not NVIDIA driver.

orin安装pytorch

error: ‘class torch::Library’ has no member named ‘set_python_module’ 22

1
2
3
4
git clone https://github.com/pytorch/vision torchvision
cd torchvision
git checkout v0.16.0
python setup.py install

安装timm

> link <

> package <

1
2
wget <package>.whl
pip install <package>.whl

数据集

下载数据集

用 wget 下载 KITTI 上的数据

先开代理。

1
wget -b <link>.zip

查看进度

1
tail -f wget-log

解压

1
unzip <name>.zip

从drive google下载

> link <

测试

一文解决 RuntimeError: CUDA out of memory. 全网最全

> link <

1
2
with torch.no_grad():
depth_pred = model(rgb)

Linux的一些操作

读取当前路径下的文件总大小

1
du -sh