常用软件配置

1. ubuntu源设置

1.1 设置中选择源
setting -> software&updates -> other -> china

2. pip源设置

2.1 指定安装源

pip install 要安装的包 -i https://pypi.tuna.tsinghua.edu.cn/simple
pypi 清华大学源:https://pypi.tuna.tsinghua.edu.cn/simple
pypi 豆瓣源 :http://pypi.douban.com/simple/
pypi 腾讯源:http://mirrors.cloud.tencent.com/pypi/simple
pypi 阿里源:https://mirrors.aliyun.com/pypi/simple/
pypi 默认官方源: https://pypi.org/simple

2.2 可以把清华源设置为默认源(首先要把pip升级到10以上)

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3. git本地账户设置

3.1 设置git用户名/邮箱

git config --global user.name [username]
git config --global user.email [email]

3.2 保存信息,避免每次输入

echo "[credential]" >> .git/config
echo "    helper = store" >> .git/config

4. 安装特定版本的python

4.1 安装python3.7

wget http://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
tar -xvzf Python-3.7.1.tgz
cd Python-3.7.1
./configure --with-ssl
make
sudo make install
PATH=$PATH:$HOME/bin:/usr/local/python3.7.1/bin

4.2 修改软连接

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3.7 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip3 /usr/bin/pip

4.3 相关错误

Q1: 报ssl module in Python is not available的错误
A: https://blog.csdn.net/zr1076311296/article/details/75136612

Q2: 报zipimport.ZipImportError: can’t decompress data; zlib not available in Linux
A: sudo apt-get install zlib*

Q3: sqlite
A: 参考:https://www.jianshu.com/p/dd4532457b9f

5. Docker

5.1 错误

  • Q: Error response from daemon: Get https://registry-1.docker.io/v2/ ... read: connection refused
  • A: CSDN资料
  • A: 简书资料

5.2 pull镜像修改,加快下载速度
/etc/docker/daemon.json文件中添加下面参数,此处使用的是中国科技大学的docker镜像源

{
   "registry-mirrors" : ["https://docker.mirrors.ustc.edu.cn"],
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }

}

6. 安装tensorflow_GPU版,需要NVIDIA+CUDA+cuDNN

6.1 安装的是TensorFlow2,与安装TensorFlow1.x有差别

TensorFlow相应版本对应的CUDA和cuDNN,页面底部

#版本:tensorflow=2.1.0 CUDA=10.1.243-1 cuDNN=7.6.5.32-1+cuda10.1

# Add NVIDIA package repositories
# Add HTTPS support for apt-key

$ sudo apt-get install gnupg-curl
$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_10.1.243-1_amd64.deb
$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
$ sudo dpkg -i cuda-repo-ubuntu1604_10.1.243-1_amd64.deb
$ sudo apt-get update
$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb
$ sudo apt install ./nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb
$ sudo apt-get update

# Issue with driver install requires creating /usr/lib/nvidia
sudo mkdir /usr/lib/nvidia

# Install NVIDIA driver 安装cuda时会自动安装适合自己的NVIDIA驱动
# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
    cuda-10-1 \
    libcudnn7=7.6.5.32-1+cuda10.1  \
    libcudnn7-dev=7.6.5.32-1+cuda10.1
# Reboot. Check that GPUs are visible using the command: nvidia-smi

# Install TensorRT. Requires that libcudnn7 is installed above.
sudo apt-get install -y --no-install-recommends \
    libnvinfer6=6.0.1-1+cuda10.1 \
    libnvinfer-dev=6.0.1-1+cuda10.1 \
    libnvinfer-plugin6=6.0.1-1+cuda10.1

#查看已经暗转的cuda和NVIDIA
$ sudo dpkg -l |grep cuda
$ sudo lspci | grep -i nvidia

6.2 安装的是TensorFlow相关

TensorFlow相应版本对应的CUDA和cuDNN,页面底部

#版本:tensorflow=1.14.0 CUDA=10.0.130-1 cuDNN=7.4.1.5 TensorRT=5.1.5-1+cuda10.0

# Add NVIDIA package repositories
# Add HTTPS support for apt-key

$ sudo apt-get install gnupg-curl
$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_10.0.130-1_amd64.deb
$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
$ sudo dpkg -i cuda-repo-ubuntu1604_10.0.130-1_amd64.deb
$ sudo apt-get update
$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb
$ sudo apt install ./nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb
$ sudo apt-get update

# Issue with driver install requires creating /usr/lib/nvidia
sudo mkdir /usr/lib/nvidia

# Install NVIDIA driver 安装cuda时会自动安装适合自己的NVIDIA驱动
# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
    cuda-10-0 \
    libcudnn7=7.4.1.5-1+cuda10.0  \
    libcudnn7-dev=7.4.1.5-1+cuda10.0
# Reboot. Check that GPUs are visible using the command: nvidia-smi

# Install TensorRT. Requires that libcudnn7 is installed above.
sudo apt-get install -y --no-install-recommends \
    libnvinfer5=5.1.5-1+cuda10.0 \
    libnvinfer-dev=5.1.5-1+cuda10.0 \

#libnvinfer5_5.1.5-1+cuda10.0_amd64.deb

6.2 测试tensorflow GPU版是否安装成功

$ import tensorflow as tf
$ tf.test.is_gpu_available()

6.3 tensorflow不能使用GPU提示:

W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libcublasLt.so.10: cannot open shared object file: No such file or directory;
W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libcublasLt.so.10: cannot open shared object file: No such file or directory; 
W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
# 经过搜索发现libnvinfer.so.6 位于/usr/lib/x86_64-linux-gnu/ libcublasLt.so.10位于/usr/local/cuda-10.2/targets/x86_64-linux/lib/lib
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64
$ sudo cp /usr/lib/x86_64-linux-gnu/libnvinfer* /usr/local/cuda/targets/x86_64-linux/lib
$ sudo cp /usr/local/cuda-10.2/targets/x86_64-linux/lib/lib* /usr/local/cuda/targets/x86_64-linux/lib

7. 键鼠共享

安家的参考博客

posted @ 2020-12-18 15:38  libbin  阅读(503)  评论(0编辑  收藏  举报