Python 开发环境搭建
Python 开发环境搭建
flyfish
版本
Ubuntu 22.04.5 LTS
PyTorch 2.5.1
cuda 12.4
python 3.12.7
安装 Anaconda3
依赖
sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
安装命令
./Anaconda3-2024.10-1-Linux-x86_64.sh -h
usage: ./Anaconda3-2024.10-1-Linux-x86_64.sh [options]Installs Anaconda3 2024.10-1-b run install in batch mode (without manual intervention),it is expected the license terms (if any) are agreed upon
-f no error if install prefix already exists
-h print this help message and exit
-p PREFIX install prefix, defaults to /home/sss/anaconda3, must not contain spaces.
-s skip running pre/post-link/install scripts
-m disable the creation of menu items / shortcuts
-u update an existing installation
-t run package tests after installation (may install conda-build)
根据提供的选项,可以以不同的方式定制安装过程。简要说明:
-b
: 以批处理模式运行安装程序,不需要用户干预。选择此选项即表示同意所有许可条款(如果有)。-f
: 如果安装目标位置已经存在,不会报错。这在你想覆盖现有安装时可能会用到。-h
: 显示帮助信息并退出。这是获取命令行参数信息的好方法。-p PREFIX
: 指定安装路径,默认是 /home/sss/anaconda3。确保指定的路径中不包含空格。-s
: 跳过执行预链接、后链接或安装脚本。这可以加快安装速度,但可能会影响某些包的功能。-m
: 禁用创建菜单项或快捷方式。如果你不想在桌面环境中添加Anaconda的启动器,可以选择这个选项。-u
: 更新已有的 Anaconda 安装。这会保留现有的环境和设置,并仅更新核心组件。-t
: 在安装后运行包测试(可能会安装conda-build
)。这对于确保所有包都能正常工作很有用,但在常规安装中通常不需要。
/home/sss/anaconda3
其中sss
是自己的用户名
例如,如果想在没有用户交互的情况下将 Anaconda 安装到 /opt/anaconda3
目录,并且该目录如果已经存在也不会报错,可以使用以下命令:
./Anaconda3-2024.10-1-Linux-x86_64.sh -b -f -p /opt/anaconda3
激活Anaconda环境
sss@sss-Super-Server:~$ source ./anaconda3/bin/activate
(base) sss@sss-Super-Server:~$ conda init
no change /home/sss/anaconda3/condabin/conda
no change /home/sss/anaconda3/bin/conda
no change /home/sss/anaconda3/bin/conda-env
no change /home/sss/anaconda3/bin/activate
no change /home/sss/anaconda3/bin/deactivate
no change /home/sss/anaconda3/etc/profile.d/conda.sh
no change /home/sss/anaconda3/etc/fish/conf.d/conda.fish
no change /home/sss/anaconda3/shell/condabin/Conda.psm1
no change /home/sss/anaconda3/shell/condabin/conda-hook.ps1
no change /home/sss/anaconda3/lib/python3.12/site-packages/xontrib/conda.xsh
no change /home/sss/anaconda3/etc/profile.d/conda.csh
modified /home/sss/.bashrc==> For changes to take effect, close and re-open your current shell. <==(base) sss@sss-Super-Server:~$
安装 ModelScope SDK
pip install modelscope
安装 PyTorch
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
https://pytorch.org/get-started/locally/
安装 transformers
pip install transformers
安装 VS Code
sudo snap install --classic code