ubuntu利用conda创建虚拟环境,安装 cuda,cudnn,pytorch,远程访问 jupyter notebook

本文详细介绍如何使用Anaconda进行Python环境的搭建与管理,包括安装Anaconda、创建及激活虚拟环境、配置国内镜像源、安装GPU相关库(CUDA、cuDNN)、安装PyTorch等深度学习框架及Jupyter Notebook等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cd到安装包所在目录,安装:

bash Anaconda3-5.1.0-Linux-x86_64.sh

创建虚拟环境:

conda create -n your_env_name python=3.6

激活虚拟环境:

source activate your_env_name

添加conda国内镜像:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

安装cuda:

conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/

安装cudnn:

conda install cudnn=7.0.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

安装pytorch、torchvision指定版本:

conda install pytorch=0.3.0 torchvision=0.2.0 -c soumith

安装jupyter notebook:

conda install notebook

ssh远程连接:
https://blog.youkuaiyun.com/lxfhahaha/article/details/73650096
https://blog.youkuaiyun.com/kaixinjiuxing666/article/details/80118714

ssh -L6789:localhost:8889 name(远程服务器的用户名)@ip(远程服务器的IP)

在已经成功连接的服务器环境中,打开 notebook:

jupyter notebook

在本地浏览器中打开 notebook:

http://localhost:6789

在本地浏览器中输入notebook密钥:

刚才在远程服务器打开notebook后,系统自动跳出的toke= 后面的那一串

注:

  • pytorch 中文官网:
http://pytorch.apachecn.org/
  • 安装conda完成后,输入:conda list , 若出现未找到命令,则需修改环境变量(此法每次开机后都要修改,也可修改配置文件永久生效):
export PATH=~/anaconda3/bin:$PATH
  • 每个不同镜像网站里面包含各种不同的下载包,可根据自己的需求打开查找对应的安装包:
    如 cudatoolkit 8.0.3 在https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/内,

则安装命令如下:

conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值