记pytorch 0.4.1caffe2源码安装

记pytorch 0.4.1caffe2源码安装

最新安装detectron命令(2019.11.25 update)

echo "Installing pytorch"
cd ~/Documents/pytorch
if [ ! -d ~/Documents/pytorch/pytorch ]; then
	git clone https://github.com/pytorch/pytorch.git
fi
cd pytorch
git checkout v1.2.0

sudo pip3 install -r requirements.txt
sudo pip3 install -r caffe2/requirements.txt
sudo pip3 install protobuf

git submodule sync
git submodule update --init --recursive
sudo rm -rf build
sudo USE_OPENCV=On USE_LMDB=On BUILD_BINARY=On python3 setup.py install


echo "Installing vision"
cd ~/Documents/pytorch
if [ ! -d ~/Documents/pytorch/vision ]; then
	git clone https://github.com/pytorch/vision.git
fi
cd vision
git checkout v0.4.0

git submodule sync
git submodule update --init --recursive
sudo python3 setup.py install

以下为基于pytorch 0.4.1的版本,其实命令变化不大,都可以参考。
  1. 下载源码

    git clone https://github.com/pytorch/pytorch.git && cd pytorch
    

image-20181022163539834

  1. 运行命令git checkout v0.4.1

image-20181022163849883

  1. 运行命令git submodule update —-init

image-20181022163952607

  1. 运行命令
mkdir build
cd build
cmake ..
make -j4

果然又是一大堆错

报错一:具体见下图

[  1%] Built target js_embed
[  1%] Performing build step for 'nccl_external'
make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
Scanning dependencies of target cpuinfo
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
[  3%] Built target libprotobuf-lite
/bin/sh: 1: [: -lt: unexpected operator
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
Scanning dependencies of target pthreadpool
[  3%] Building C object confu-deps/cpuinfo/CMakeFiles/cpuinfo.dir/src/init.c.o
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory

image-20181022165418901

解决:

加入环境变量:

vim ~/.bashrc 
#在最后一行加入以下
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
#保存并退出
source ~/.bashrc #使.bashrc立即生效

报错二:具体见下图

make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
/bin/sh: 1: [: -lt: unexpected operator
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
[  1%] Building CXX object third_party/protobuf/cmake/CMakeFiles/libprotobuf.dir/__/src/google/protobuf/arena.cc.o
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
ls: cannot access '/usr/lib64/libcudart.so.*': No such file or directory
Compiling src/libwrap.cu                      > /home/chenzhiwei/Documents/pytorch/third_party/nccl/build/obj/libwrap.o
nvcc fatal   : Unsupported gpu architecture 'compute_60'
Makefile:136: recipe for target '/home/chenzhiwei/Documents/pytorch/third_party/nccl/build/obj/libwrap.o' failed
make[3]: *** [/home/chenzhiwei/Documents/pytorch/third_party/nccl/build/obj/libwrap.o] Error 1
CMakeFiles/nccl_external.dir/build.make:110: recipe for target 'nccl_external-prefix/src/nccl_external-stamp/nccl_external-build' failed
make[2]: *** [nccl_external-prefix/src/nccl_external-stamp/nccl_external-build] Error 2
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/nccl_external.dir/all' failed
make[1]: *** [CMakeFiles/nccl_external.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

image-20181022170054487

解决:

还是添加环境变量吧:

image-20181024102455954

可以复制下面的?

# CUDA
export PATH=/usr/local/cuda/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

#MKL
#export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:$LD_LIBRARY_PATH

#opencv
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
export PATH=/usr/local/bin/:$PATH
export LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH
export CPATH=/usr/local/include/:$CPATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

#matlab
#export MATLAB_ROOT=/usr/local/MATLAB/R2014b

#CAFFE
#export PYTHONPATH=/home/shenyunhang/Documents/caffe/python:$PYTHONPATH

# vim
export EDITOR=vim

———————————————吐血————————还是不行————————

然后我把所有文件都删了,从第一步开始安装。

这个时候检查了一下cuda啥的版本,发现使用的是cuda 9.2.148,其对应的显卡驱动版本为396.54。发现显卡驱动为不对,接下来就是安装显卡驱动了。

cuda 9.2

  • nvidia driver 396.54
  • cuda 9.2 (not install driver,install toolkit and samples)
  • cudnn 7.1.4 for cuda9.2 (for TensorRT) caffe,tensorflow, baidu anakin

cuda 8.0

  • nvidia driver 384.130
  • cuda 8.0 (not install driver,install toolkit and samples)
  • cudnn 6.0.21 for cuda8.0 caffe
安装显卡驱动nvidia driver 396.54

1)卸载原来显卡驱动:

sudo apt-get remove --purge nvidia- #这里按tab键可以看到已安装的驱动版本
sudo apt-get remove --purge nvidia-384 #本人运行的命令

2)安装nvidia driver 396.54:

安装显卡驱动推荐使用官方ppa源的方式进行安装,使用cuda_xxx_linux.run文件离线安装会导致循环登录问题。

sudo add-apt-repository ppa:graphics-drivers/ppa
sudp apt-get update

sudo apt-cache search nvidia-*
# nvidia-384
# nvidia-396
sudo apt-get -y install nvidia-396

# test #这一步需要重启后才能正常输出
sudo nvidia-smi

按照前面的步骤:

image-20181023154940539

终于100%了。。。。

最后,我们来测试一下是否安装成功啦:

image-20181024105000819

命令汇总:

git clone https://github.com/pytorch/pytorch.git
cd pytorch
git checkout v0.4.1
git submodule update --init
mkdir build
cd build
cmake ..
make -j4
sudo make install -j
git submodule update --init
mkdir build && cd build
cmake -DCMAKE_CXX_FLAGS="-isystem /home/chenzhiwei/Documents/pytorch/third_party/eigen -isystem /home/chenzhiwei/Documents/pytorch/third_party/cub" ..
make 
cd ..
make 
ln -s /home/xxx/Dataset/voc2007/annotations annotations
ln -s /home/xxx/Dataset/voc2007/JPEGImages JPEGImages
ln -s /home/xxx/Dataset/voc2007/VOCdevkit2007 VOCdevkit2007
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
安装PyTorch 0.4.1,你可以按照以下步骤进行操作: 1. 首先确保你已经安装了Python。PyTorch需要Python 3.5 或更高版本。你可以在命令行中输入 `python --version` 来检查你当前的Python版本。 2. 接下来,确定你是否已经安装了合适的CUDA版本(如果你计划在GPU上运行PyTorch)。PyTorch 0.4.1 需要 CUDA 8.0 或更高版本。 3. 访问PyTorch的官方网站(https://pytorch.org/get-started/previous-versions/)并选择适合你系统的安装选项。在这个页面上,你可以找到特定操作系统和Python版本的安装命令。 4. 根据你的系统和Python版本,在命令行中运行相应的安装命令。下面是一些示例命令: - 通过pip安装(如果你的系统上没有CUDA): ``` pip install torch==0.4.1 ``` - 通过conda安装(如果你使用Anaconda环境): ``` conda install pytorch=0.4.1 torchvision -c pytorch ``` - 如果你的系统支持CUDA并且你想要在GPU上运行,可以使用特定的CUDA版本。例如,使用下面的命令安装 CUDA 9.0 版本: ``` conda install pytorch=0.4.1 torchvision cudatoolkit=9.0 -c pytorch ``` 5. 等待安装过程完成。一旦安装成功,你就可以通过导入PyTorch库来验证安装是否成功。在Python中运行以下代码进行验证: ```python import torch print(torch.__version__) ``` 如果输出显示为0.4.1,则表示PyTorch 0.4.1已成功安装在你的系统上。 希望这能帮助你成功安装PyTorch 0.4.1!如果你有任何其他问题,请随时问我。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值