Linux生态之深度学习环境

这篇博客详细介绍了在Linux Ubuntu系统中搭建深度学习环境的步骤,包括驱动安装、Apex库的使用、PyTorch3D和PyTorch及其torchvision的版本安装、CUDA版本查询、RegTR环境配置、GCC的安装以及利用清华源加速下载,并提到了shell脚本在环境构建中的应用。
摘要由CSDN通过智能技术生成

驱动安装

#查看推荐的驱动版本
(1)ubuntu-drivers devices
#安装相应版本驱动
(2)sudo apt install nvidia-driver-470
#安装完成后重启

在这里插入图片描述

Apex

git clone git://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir ./

# 遇到问题:AttributeError: module 'torch.distributed' has no attribute '_all_gather_base'
git clone https://github.com/ptrblck/apex.git
cd apex
git checkout apex_no_distributed
pip install -v --no-cache-dir ./

视觉任务相关包安装

# ModuleNotFoundError: No module named 'nuscenes'
pip3 install nuscenes-devkit==1.0.5
# ModuleNotFoundError: No module named 'sklearn'
pip install scikit-learn
# 可以清除pip缓存
pip cache purge

pytorch3d 安装

pytorch3d 0.6.2适合cuda11.0+, pytorch3d 0.5.0适合cuda0.10.2
[release](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.6.2)下载pytorch3d-0.6.2 然后安装:
cd pytorch3d-0.6.2
pip install -e .  
验证下是否能成功import
import pytorch3d
from pytorch3d.ops import knn_points

pytorch和torchvision各版本安装

[pytorch和torchvision wheel文件下载](http://download.pytorch.org/whl/torch_stable.html)

查看cuda版本

nvcc -v

RegTR 环境安装

# 安装pytorch
conda install pytorch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1 cudatoolkit=11.3 -c pytorch -c conda-forge
conda install -c fvcore -c iopath fvcore iopath
# 下载 pytorch3d-0.6.0 安装包
cd pytorch3d-0.6.0
pip install -e .
# 安装其他包
pip install open3d h5py gitpython
# 安装MinkowskiEngine
sudo apt install build-essential python3-dev libopenblas-dev
git clone https://github.com/NVIDIA/MinkowskiEngine.git
cd MinkowskiEngine
python setup.py install --blas_include_dirs=/data/usr/local/cuda/include --blas=openblas

安装GCC

安装gcc 9.0的方法可以参考以下步骤:

1. 首先,更新软件包列表:
 sudo apt-get update

2. 添加gcc 9.0的个人包存储库:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test

3. 更新软件包列表:
sudo apt-get update

4. 安装gcc 9.0:
sudo apt-get install gcc-9
安装完成后,可以使用以下命令查看安装的gcc版本:
gcc --version
如果需要将gcc 9.0设置为默认的gcc编译器版本,可以使用以下命令:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100
这样就会将gcc 9.0设置为默认的gcc版本。如果需要切换回旧版本的gcc编译器,可以使用以下命令:
sudo update-alternatives --config gcc
然后选择需要的版本进行更改。

清华源

pip install opencv-python  -i https://pypi.tuna.tsinghua.edu.cn/simple

其他问题

报错信息:
nvcc fatal   : Unsupported gpu architecture 'compute_86'
error: command '/usr/local/cuda-11.0/bin/nvcc' failed with exit code 1
解决办法:
export TORCH_CUDA_ARCH_LIST="7.5"

shell scripts

您可以使用sed命令来实现替换操作。以下是一个使用sed替换文件名中的字符串的示例命令:

find . -name '*_labelTrainIds.png' -type f -print0 | while read -d $'\0' file
do
   mv "$file" "$(echo "$file" | sed 's/_labelTrainIds.png/_labelIds.png/')"
done

这个命令首先使用find命令查找所有扩展名为_labelTrainIds.png的文件,并将它们通过管道传递给while循环,然后在循环中使用sed命令替换文件名中的字符串。由于文件名可能包含空格或其他特殊字符,因此使用了-print0和read -d $'\0'来处理文件名中的空格。
这个命令会逐个重命名文件,如果原文件名是example_labelTrainIds.png,则会将其重命名为example_labelIds.png。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知行SUN

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值