wsl2 cuda

--------------------------------------- 更新ubnutu基础环境 ---------------------------------------

apt升级

sudo apt update
sudo apt upgrade
sudo apt-get update
sudo apt-get upgrade

JAVA

sudo apt install openjdk-8-jdk

sudo apt install openjdk-11-jdk

HelloWorld.java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

解释性运行文件

java HelloWorld.java

编译性运行文件

javac HelloWorld.java

java HelloWorld

java -version

安装 gcc,g++

sudo apt install gcc g++ gdb cmake

pip升级

sudo apt install python3-pip
python3 -m pip install --upgrade pip

卸载pip

sudo apt-get remove python3-pip

cd /mnt/c/Users/29038/Downloads/

--------------------------------------- 安装cuda ---------------------------------------

wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
sudo sh cuda_11.1.0_455.23.05_linux.run

--------------------------------------- 安装cudnn ---------------------------------------

解压

sudo tar zxvf cudnn-11.1-linux-x64-v8.0.4.30.tgz

cudnn 复制

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*

--------------------------------------- cuda,cudnn 添加环境变量 / nvidia-smi, nvcc -V 添加环境变量---------------------------------------

打开 .bashrc 文本
vim ~/.bashrc

文本最后添加

echo "export PATH=$PATH:/usr/local/cuda/bin" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64" >> ~/.bashrc
echo "export CUDA_HOME=$CUDA_HOME:/usr/local/cuda" >> ~/.bashrc



export PATH=/usr/local/cuda-11.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-11.1

更新文本/更新环境变量

source ~/.bashrc

解决缺少libcusolver.so.10文件问题

sudo cp /usr/local/cuda/lib64/libcusolver.so.11 /usr/local/cuda/lib64/libcusolver.so.10

--------------------------------------- 安装tensorflow, pytorch ---------------------------------------

tensorflow 安装

pip3 install tensorflow==2.4.1

tensorflow 测试GPU是否可用

python3
import tensorflow as tf
print(tf.test.is_gpu_available())

pytorch 安装

pip3 install torch1.8.1+cu111 torchvision0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

pytorch 测试GPU是否可用

python3
import torch
print(torch.cuda.is_available())
print(torch.Tensor(5, 3).cuda())

--------------------------------------- 安装anaconda3/miniconda3 ---------------------------------------

vim ~/.bashrc
export PATH= P A T H : / h o m e / z h u y e t u o / m i n i c o n d a 3 / b i n e x p o r t P A T H = PATH:/home/zhuyetuo/miniconda3/bin export PATH= PATH:/home/zhuyetuo/miniconda3/binexportPATH=PATH:/home/zhuyetuo/anaconda3/bin

设置jupyter密码

jupyter notebook passwd

--------------------------------------- 安装docker ---------------------------------------

--------------------------------------- 安装nvidia-docker ---------------------------------------

apt-get install gcc-7 g+±7
sudo apt install gcc make g++

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50

python3
import tensorflow as tf
import os

os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘2’ # 不显示等级2以下的提示信息

print(‘GPU’, tf.test.is_gpu_available())

a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
curl -sSL https://get.daocloud.io/docker | sh

手动安装docker

sudo apt-get remove docker docker-engine docker.io containerd runc

sudo apt-get update

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

sudo add-apt-repository “deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ $(lsb_release -cs) stable”

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

安装指定版本

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

apt-cache madison docker-ce

sudo service docker start

sudo docker run hello-world

使用 Docker 作为非 root 用户

sudo usermod -aG docker zhuyetuo

卸载 docker

sudo apt-get purge docker-ce

删除镜像、容器、配置文件等内容

sudo rm -rf /var/lib/docker

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值