Windows10 子系统Ubuntu18 搭建深度学习环境

最终尝试还是失败了,没时间继续研究,但是一些过程的配置以后可以参考
参考以下链接,将CentOS的安装转换成了Windows10的子系统Ubuntu18的安装
centos7 手把手从零搭建深度学习环境 (以TensorFlow2.0为例)

搭建Ubuntu子系统

通过微软商店安装Ubuntu18版本

安装NVIDIA组件

1. 安装CUDA

CUDA仓库

下载外城后,页面安装中有提示运行命令符,可以直接运行

sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

sudo apt-key add /var/cuda-repo-/7fa2af80.pub 这一句根据版本来修改。且可以先执行。

安装之前,修改点

  1. 修改数据源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
#国内几个主要的ubuntu软件源:https://blog.csdn.net/qq_34889607/article/details/82500602?utm_source=blogxgwz0
#在此使用的清华源
 
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
  1. 补充DNS
sudo vi /etc/resolv.conf

追加以下内容

nameserver  202.96.134.133
nameserver  202.96.128.68

否则在执行 以下命令时会报错

sudo apt-get install cuda
E: Failed to fetch

全部设置完成后,运行成功

Windows10 子系统Ubuntu18 搭建深度学习环境_第1张图片

安装成功后,配置环境

sudo vim ~/.bashrc

然后在bashrc文件里添加下面配置

export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}

2. 安装CuDNN

  • CuDNN是深度神经网络库,和CUDA搭配使用,专门用于深度学习任务

CuDNN仓库

在仓库中把版本信息产开后

Download cuDNN v7.6.4 (September 27, 2019), for CUDA 10.0

选择

cuDNN Developer Library for Ubuntu18.04 (Deb)

安装cuDNN
Windows10 子系统Ubuntu18 搭建深度学习环境_第2张图片

直接下载Linux版本,执行

 tar -xzvf cudnn-10.0-linux-x64-v7.6.4.38.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*

运行下面的代码,检查是否安装成功

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

出现下面的内容,表示安装成功

root@LAPTOP-OU4CRP0L:/mnt/d/install# tar -xzvf cudnn-10.0-linux-x64-v7.6.4.38.tgz
cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.6.4
cuda/lib64/libcudnn_static.a
root@LAPTOP-OU4CRP0L:/mnt/d/install# sudo cp cuda/include/cudnn.h /usr/local/cuda/include
root@LAPTOP-OU4CRP0L:/mnt/d/install# sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
root@LAPTOP-OU4CRP0L:/mnt/d/install# sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
root@LAPTOP-OU4CRP0L:/mnt/d/install# cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 4

#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

补充一个下面的内容,安装时出错了,暂时没解决
下载完成后,也可下载下面的版本

sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.0_amd64.deb

报错

dpkg: dependency problems prevent configuration of libcudnn7-dev:
 libcudnn7-dev depends on libcudnn7 (= 7.6.5.32-1+cuda10.0); however:
  Package libcudnn7 is not installed.

当前没解决TODO

3. 安装NVIDA显卡驱动

NVIDIA官网
3.1 去官网下载相应的驱动

3.2 输入以下命令

echo -e "blacklist nouveau\noptions nouveau modeset=0" > /etc/modprobe.d/blacklist.conf

3.3 输入 lsmod | grep nouveau 如果没有输入任何内容,说明成功禁止了nouveau
3.4 输入./NVIDIA-Linux-x86_64-460.39.run 安装驱动

报错

You do not appear to have an NVIDIA GPU supported by the 460.39 NVIDIA Linux graphics driver installed in this system.

sudo sh NVIDIA-Linux-x86_64-460.39.run --add-this-kernel
报错

Unable to find the kernel source tree for the currently running kernel.

解决方案 还没解决。。。

  1. 使用命令,查看你使用的是:uname -r
    我的结果是 :

5.4.72-microsoft-standard-WSL2

从 Ubuntu 官方内核库中下载
Linux Kernel 5.4.72
下载了以下三个文件

linux-headers-5.4.72-050472-generic_5.4.72-050472.202010170535_amd64.deb
linux-headers-5.4.72-050472_5.4.72-050472.202010170535_all.deb
linux-image-unsigned-5.4.72-050472-generic_5.4.72-050472.202010170535_amd64.deb

安装

sudo dpkg -i *.deb

Building module:
cleaning build area…(bad exit status: 2)
unset ARCH; env NV_VERBOSE=1 ‘make’ -j8 NV_EXCLUDE_BUILD_MODULES=’’ KERNEL_UNAME=5.4.72-050472-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.4.72-050472-generic/build LD=/usr/bin/ld.bfd modules…(bad exit status: 2)
ERROR (dkms apport): kernel package linux-headers-5.4.72-050472-generic is not supported
Error! Bad return status for module build on kernel: 5.4.72-050472-generic (x86_64)
Consult /var/lib/dkms/nvidia/410.48/build/make.log for more information.
…done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.72-050472-generic
W: mkconf: MD subsystem is not loaded, thus I cannot scan for arrays.
W: mdadm: failed to auto-generate temporary mdadm.conf file.

ubuntu18.04 server安装nvidia驱动NVIDIA-Linux-x86_64-450.57
http://www.elecfans.com/news/1117346.html

你可能感兴趣的:(经验分享,深度学习,ubuntu)