手把手教你安装PaddleDetection(最新CUDA11.7版本)
本文记录一下在linux系安装PaddleDetection的过程,使用Conda的方式来安装;(尝试过docker的方式,无法获取镜像;尝试过pip的方式,提升找不到库;最终使用Conda成功安装了。目录前言一、设置国内源加速Conda二、创建Conda环境三、安装PaddlePaddle四、安装PaddleDetection。
前言
本文记录一下在linux系安装PaddleDetection的过程,使用Conda的方式来安装;
(尝试过docker的方式,无法获取镜像;尝试过pip的方式,提升找不到库;最终使用Conda成功安装了。)
目录
一、设置国内源加速Conda
在Linux系统中,通过修改condarc文件,进行配置conda的源
vim ~/.condarc
改为如下所示:
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
二、创建Conda环境
创建一个Conda环境,名称为PaddleDetection,指定python的版本为3.8
conda create -n PaddleDetection python=3.8
进入环境
conda activate PaddleDetection
三、安装PaddlePaddle
首先来到官网,选择合适的CUDA版本,我选择了最新的CUDA11.7
根据上图的安装信息(命令),进行安装;
conda install paddlepaddle-gpu==2.4.2 cudatoolkit=11.7 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge
然后配置环境变量(不配置的,在使用时会出现如下错误)
dynamic_loader.cc:307] The third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctly. (error code is /usr/local/cuda/lib64/libcudnn.so: cannot open shared object file: No such file or directory)
用conda env list,查询环境的路径
(PaddleDetection) root@bap3ac2457:/guopu # conda env list
# conda environments:
#
base /opt/conda
PaddleDetection * /opt/conda/envs/PaddleDetection
能看到刚创建的Conda的路径为 /opt/conda/envs/PaddleDetection
添加/opt/conda/envs/PaddleDetection/lib/到环境变量中.bashrc
echo "export LD_LIBRARY_PATH=/opt/conda/envs/PaddleDetection/lib/">>~/.bashrc
测试是否安装成功
# 确认PaddlePaddle安装成功
python -c "import paddle; paddle.utils.run_check()"
# 确认PaddlePaddle版本
python -c "import paddle; print(paddle.__version__)"
看到成功打印信息
(PaddleDetection) root@bap3ac2457:/guopu# python -c "import paddle; paddle.utils.run_check()"
Running verify PaddlePaddle program ...
W0508 08:48:03.937019 44515 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 11.8, Runtime API Version: 11.7
W0508 08:48:03.950474 44515 gpu_resources.cc:91] device: 0, cuDNN Version: 8.4.
PaddlePaddle works well on 1 GPU.
PaddlePaddle works well on 1 GPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
(PaddleDetection) root@bap3ac2457:/guopu#
四、安装PaddleDetection
首先下载PaddleDetection代码
git clone https://github.com/PaddlePaddle/PaddleDetection.git
进入工程目录
cd PaddleDetection
使用pip安装依赖,可以使用 -i https://pypi.tuna.tsinghua.edu.cn/simple 加速安装
pip install -r requirements.txt
如果安装pycocotools报错了,参考https://blog.csdn.net/weixin_57096837/article/details/122775990
编译安装paddledet
python setup.py install
如果出现下载一些库错误,比如pyclipper,那么手动安装:pip install pyperclip,再执行python setup.py install
如果出现error: protobuf 3.20.0 is installed but protobuf>=3.20.2 is required by {'onnx'},执行:pip install protobuf==3.20.3
测试环境
安装后确认测试通过:
python ppdet/modeling/tests/test_architectures.py
测试通过后会提示如下信息:
(PaddleDetection) root@bap3ac2457:/guopu/PaddleDetection# python ppdet/modeling/tests/test_architectures.py
Warning: Unable to use numba in PP-Tracking, please install numba, for example(python3.7): `pip install numba==0.56.4`
Warning: Unable to use numba in PP-Tracking, please install numba, for example(python3.7): `pip install numba==0.56.4`
W0510 00:52:22.579213 47617 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 11.8, Runtime API Version: 11.7
W0510 00:52:22.590267 47617 gpu_resources.cc:91] device: 0, cuDNN Version: 8.4.
.......
----------------------------------------------------------------------
Ran 7 tests in 3.731s
OK
(PaddleDetection) root@bap3ac2457:/guopu/PaddleDetection#
如果打印以上信息,说明安装完成啦~
更多推荐
所有评论(0)