- 指定在哪些gpu跑
torch.cuda.set_device(7)###设置7好gpu
d2l.try_gpu()#当前gpu
- conda批量安装
conda install --file=requirements.txt
pip install --r requirements.txt
- cuda对应的torch版本
后面需要指定网址如
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
- conda env clone
conda create --name python32(新名字) --clone python321(老名字)
conda remove --name old_name --all
- 对torch.tensor的元素进行判定,最后设为目标值,也就是矩阵对应元素运算
torch.where(condition,a,b)
- np的数组方法
如:where(condition,x,y) where(condition) argwhere(condition)
使用numpy提供的函数concatenate((a1,a2,…,an),axis = 0)
axis = 0, 按行拼接
axis = 1, 按列拼接