Pytracking

配置过程

我的环境是ubuntu20.04,从windows过来的,懂的都懂,显卡是3060
cuda驱动:NVIDIA-Linux-x86_64-510.54.run
感谢这位博主的博客:Ubuntu20.04下深度学习环境配置

一、换国内源

pip install 包名 -i http://pypi.douban.com/simple –trusted-host pypi.douban.com
使用gedit文本编辑器打开sources.list进行修改sudo gedit /etc/apt/sources.list将目前的源全部注释掉,、Ubuntu阿里源##**加入ubuntu 20.04(focal) 配置如下 **下面的源,换完后别忘了更新一下。
$sudo apt-get update
$sudo apt-get upgrade
$sudo apt-get Install vim

二、gpu驱动

记得关闭安全启动security boot且是在安装驱动之前,小编真是被它坑惨了(非常重要!!!!!!!!!!)
gpu驱动安装分为:1. 禁用nouveau, 2. 卸载旧的驱动(如果你是第一次安装驱动,这步可以省略),3.gcc安装,4,安装驱动
1.禁用nouveau
Ubuntu系统集成的显卡驱动程序是nouveau,它是第三方为NVIDIA开发的开源驱动,我们需要先将其屏蔽才能安装NVIDIA官方驱动。 所以我们要先把驱动加到黑名单blacklist.conf里。

$sudo chmod 666 /etc/modprobe.d/blacklist.conf

$sudo gedit /etc/modprobe.d/blacklist.conf
末尾输入:
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb


保存关闭文本后
$sudo update-initramfs -u

记得重启计算机,打开终端检查nouveau是否被禁用

$lsmod | grep nouveau \\若执行完该句,没有任何输出,则nouveau被成功禁用

安装lightdm,关闭启动图形界面用

sudo apt-get install lightdm

2.卸载旧的驱动,看你怎么安装的,先cd到安装的目录下在执行下面的,记得修改自己的驱动版本号

sudo chmod +x *.run
sudo ./NVIDIA-Linux-x86_64-510.54.run --uninstall

有的是用下面这种卸载

sudo apt-get remove --purge nvidia*

3.安装gcc

$sudo apt-get  install  build-essential \\安装gcc,不要怀疑,就是build-essential,我也不知道为啥
$gcc --version \\检查gcc是否安装成功
$sudo apt-get install g++
$sudo apt-get install make

4.下载对应版本的gpu驱动
安装gpu驱动的方法分为2种:ppa源安装和利用run文件进行安装。
这里推荐使用run文件安装。因此需要根据你的显卡类型选择合适的run文件下载,官网下载链接(速度较快,可直接使用):gpu驱动下载
5. 安装驱动
先按Ctrl+Alt+F1,关闭图形界面(过程中出现星号则证明需要输入密码)。再在新出现的界面输入以下命令:
或者按Ctrl+Alt+F3(1-6),先登录在输入命令:(非常重要,呜呜呜,懂?之前被坑惨了)

sudo telinit 3
$sudo service lightdm stop

sudo mkdir download
sudo chmod 777 /opt/download
cp /home/cmx/download/NVIDIA-Linux-x86_64-510.54.run /opt/download #注意前面的地址是你文件放的地 sudo chmod a+x NVIDIA-Linux-x86_64-510.54.run
cd /opt/download
sudo ./NVIDIA-Linux-x86_64-510.54.run  -no-x-check -no-nouveau-check -no-opengl-files
 

```python
1. There appears to already be a driver installed on your system (version:      
  390.42).  As part of installing this driver (version: 390.42), the existing  
  driver will be uninstalled.  Are you sure you want to continue? 
  Continue installation      Abort installation 
(选择 Coninue,如果是重装的话)
2. The distribution-provided pre-install script failed!  Are you sure you want
  to continue?                                                                 
 Continue installation      Abort installation       
(选择 Cotinue)
3. Would you like to register the kernel module sources with DKMS? This will    
  allow DKMS to automatically build a new module, if you install a different   
  kernel later.
Yes                       No  
(这里选 No)
4. Install NVIDIA's 32-bit compatibility libraries?
    Yes                       No  
(这里选 No)
5. Installation of the kernel module for the NVIDIA Accelerated Graphics Driver
  for Linux-x86_64 (version 390.42) is now complete.                           
  OK
6.Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up. 
    Yes                       No  
(这里选 Yes)

6.完成安装并验证$sudo service lightdm start 再按Ctrl+Alt+F7回到图形界面即可,这里一定要先按住Ctrl+Alt,再按F7,不然容易黑屏(我每次这个时候只能强制重启了)

$nvidia-smi

510.54

  1. 注意
    如果你不是第一次安装驱动,并且这次安装驱动已经距离上次安装已有较久的时间了,尽可能重新安装最新默认的gcc和在官网重新下载驱动。(我就是存了很久前下载的驱动,结果和GCC版本不匹配,一直安装出现ERROR)
    撒花!!!gpu驱动已安装完成!

三、Anaconda安装(略)

https://www.anaconda.com/products/individual

$bash Anaconda3-2020.07-Linux-x86_64.sh

然后一直按回车键,直到出现”Do you accept the license terms”, 输入”no”

出现”Anaconda3 will now be installed into this location: /home/xxx/anaconda3″,直接按回车键,安装在该目录中。

出现”Do you wish the installer to initialize Anaconda3 by running condo init?”, 输入”no”。

这时anaconda已经基本安装完成了。
区分Ubuntu自带python和anaconda中的python
Linux中会自带python, Ubuntu20.04中自带python3,已经没有python2了。这时不区分不影响anaconda的正常使用,但pytorch和tensorflow对这Linux中自带的python3和anaconda中的python的使用需求不同,后期需要进行两者的切换。所以最好在这里就对他们进行区分。
先退回到根目录

$cd ~
$sudo vim .bashrc \\利用vim打开.bashrc文件
输入i编辑
alias python3="/usr/bin/python3.8"
export PATH="/home/cmx/anaconda3/bin:$PATH"
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64
#export PATH=$PATH:/usr/local/cuda-11.4/bin
#export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-11.4

###alias python3="/usr/bin/python3.8"\\给系统自带的python起一个别名,就叫python3
###export PATH="/home/xxx/anaconda3/bin:$PATH"\\anaconda3中的python
注意esc退出,:wq!保存
$source .bashrc

试试刚才进行区分的设置。

$python \\本条命令应该启动anaconda3中的python
$exit() \\退出
$python3 \\本条命令应该启动系统的python
$exit() \\退出

cuda-toolkit安装

下载地址在这里,

https://developer.nvidia.com/cuda-toolkit-archive

官网给出了好几种包,我选的手动安装包,根据官网的提示,安装方法是这样的,例如

版本:11.4.0_470.42.01
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
sudo sh cuda_11.4.0_470.42.01_linux.run

版本:11.4.3_470.82.01

wget https://developer.download.nvidia.com/compute/cuda/11.4.3/local_installers/cuda_11.4.3_470.82.01_linux.run
sudo sh cuda_11.4.3_470.82.01_linux.run

下载的时候注意看版本,比如我的电脑提示驱动是470.86,但我没找到这个470.86的toolkit,所有cuda11.4的包我全部列在下面,我只能用一个最相近的包,版本是470.82,也就是列出来的最后一个包,

https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda_11.4.1_470.57.02_linux.run
https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run
https://developer.download.nvidia.com/compute/cuda/11.4.3/local_installers/cuda_11.4.3_470.82.01_linux.run

原文链接:https://blog.csdn.net/tanmx219/article/details/122762261
注意:把Driver前面的driver用enter键取消掉(注意,如果你前面没有安装driver的话,这里一定要勾选driver,也就是我们要装的驱动程序)

cuda-toolkit转载了别人的方法,我的版本是cuda_11.4.0_470.42.01_linux.run
cudnn-11.4-linux-x64-v8.2.2.26.tgz

根据上面的输出添加环境变量
sudo gedit ~/.bashrc
在 ~/.bashrc 的最后添加 (网上共看到三种添加内容,请根据你的版本添加,例如,11.4的就是下面这个样子,我都是用的第三种,前面两种尤其是第二种配置貌似不正确,列在这里备忘吧):
下面的自己试试看,我给忘记了,贴了别人的

第一种
export PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    
第二种
export PATH=/usr/local/cuda-11.4/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda11.4/lib64
 
第三种(* $PATH表示添加到PATH)

#alias python3="/usr/bin/python3.8"
#export PATH="/home/xxxx/anaconda3/bin:$PATH"#xxx ji de gai
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64
export PATH=$PATH:/usr/local/cuda-11.4/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-11.4

配置完环境变量之后,一定要更新一下,否则不能立即生效。也可以通过重启电脑使得环境变量生效:
$source ~/.bashrc
或者:
$source /etc/profile

最后检查一下,

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jun__2_19:15:15_PDT_2021
Cuda compilation tools, release 11.4, V11.4.48
Build cuda_11.4.r11.4/compiler.30033411_0

安装cudnn

https://developer.nvidia.com/rdp/cudnn-archive

$ tar -xzvf cudnn-11.4-linux-x64-v8.2.2.26.tgz
 
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

建虚拟环境

参考https://blog.csdn.net/qqsuiying/article/details/121593987
conda create --name pytracking python=3.7
conda activate pytracking
(不行就source代替conda)
2. Install PyTorch
由于我使用的是RTX3060不支持cuda10,正好试一下cuda11的支持情况,在pytorch官网找命令
Install PyTorch with cuda11.3
pytorch1.10.0

conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=11.3

ok 完结撒花,真的是太happy了终于OK了
最后一点微不足道:
Install matplotlib, pandas, tqdm, opencv, scikit-image, visdom, tikzplotlib, gdown, and tensorboad

conda install matplotlib pandas tqdm
pip install opencv-python visdom tb-nightly scikit-image tikzplotlib gdown
Install the coco and lvis toolkits

conda install cython
pip install pycocotools
pip install lvis
Install ninja-build for Precise ROI pooling

To compile the Precise ROI pooling module (https://github.com/vacancy/PreciseRoIPooling), you may additionally have to install ninja-build.

sudo apt-get install ninja-build
In case of issues, we refer to https://github.com/vacancy/PreciseRoIPooling.

Install spatial-correlation-sampler (only required for KYS tracker)

pip install spatial-correlation-sampler
In case of issues, we refer to https://github.com/ClementPinard/Pytorch-Correlation-extension.

Install jpeg4py

In order to use jpeg4py for loading the images instead of OpenCV’s imread(), install jpeg4py in the following way,

sudo apt-get install libturbojpeg
pip install jpeg4py
Note: The first step (sudo apt-get install libturbojpeg) can be optionally ignored, in which case OpenCV’s imread() will be used to read the images. However the second step is a must.

In case of issues, we refer to https://github.com/ajkxyz/jpeg4py.

部分源自原文链接:https://blog.csdn.net/qqsuiying/article/details/121593987
在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值