几个安装过程中遇到的坑以及对应的解决方案,一方面作为自己的记录,防止后面遇到重新查看;另一方面,如果能帮助大家解决问题,不胜欢喜。
更新国内docker镜像源方法
安装Docker Ubuntu镜像时将镜像的源更改为网易源的方法
RUN sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu\//http:\/\/mirrors.163.com\/ubuntu\//g' /etc/apt/sources.list
添加阿里云的源
另一个错误是Ubuntu “Failed to fetch”, 原因是DNS解析问题,如果在docker容器里面,可以用如下方案解决
sudo vim /etc/resolv.conf
在文件末尾添加如下两行
nameserver 223.5.5.5
nameserver 223.6.6.6
保存后运行
sudo apt-get update
即可
在Dockerfile 里面可以进行如下操作
RUN echo 'nameserver 223.5.5.5' /etc/resolv.conf
RUN echo 'nameserver 223.6.6.6' /etc/resolv.conf
RUN apt-get update
上述地址为 阿里云地址
nvidia-smi ubuntu 不可访问
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/
hash mismatch 或者超时,或者权限不够
在访问该地址https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/ ,并且下载 pub 文件到本地,如
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub > pub_file
然后在Dockerfile中添加
COPY pub_file .
RUN sudo apt-key add - < pub_file
添加清华镜像
Dockerfile 中添加
RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
python 安装文件过大,且清华镜像没有
将安装所需 whl 下载到本地,在Dockerfile中添加
COPY torch-1.3.0+cu92-cp36-cp36m-linux_x86_64.whl .
COPY torchvision-0.4.1+cu92-cp36-cp36m-linux_x86_64.whl .
RUN pip3 install torch-1.3.0+cu92-cp36-cp36m-linux_x86_64.whl
RUN pip3 install torchvision-0.4.1+cu92-cp36-cp36m-linux_x86_64.whl
参考文章
[1]: https://askubuntu.com/questions/650032/gpg-errorthe-following-signatures-were-invalid-keyexpired
[2]:https://github.com/NVIDIA/nvidia-docker/issues/571
[3]:https://blog.youkuaiyun.com/bitsec/article/details/81537125
[4]: https://blog.youkuaiyun.com/liuYinXinAll/article/details/90042947
[5]: https://stackoverflow.com/questions/28002897/wheel-file-installation