赞
踩
①进入官网传送门,下载对应的版本(Linux),然后打开terminal,将安装包上传到服务器
②当然,也可以直接在服务器通过wget指令下载:
- # 下载命令
- wget https://repo.anaconda.com/archive/Anaconda3-2023.03-Linux-x86_64.sh
一般直接放在自己文件夹下即可:/home/jst/Anaconda3-5.3.0-Linux-x86_64.sh
进入Anaconda3-5.3.0-Linux-x86_64.sh所在目录,执行以下命令:
- # 赋权命令:
- chmod +x Anaconda3-5.3.0-Linux-x86_64.sh
- # 安装命令:
- ./Anaconda3-5.3.0-Linux-x86_64.sh
安装过程一直按回车(或者按一次空格),最后输入yes同意用户许可证:
按照终端窗口中的提示,输入yes,将Anaconda的bin目录添加到系统的PATH环境变量中。这样可以方便地在终端中运行Anaconda的命令。如果不小心跳过了此步骤,参考博客[传送门]手动进行环境变量配置。是否安装VSCode,这个看个人需求,我是输入no的:
至此安装完成,重启之后就能使用啦!
- # 1. 查看conda版本
- conda --version
- # 2. 创建指定python版本的环境
- conda create --name jst python=3.8
- # 3. 激活环境
- conda activate jst
- # 4. 退出环境
- conda deactivate
- # 5. 查看所有已创建的conda虚拟环境
- conda info -e
- # 6. 克隆同设备下的conda虚拟环境(旧:A 新:B)
- conda create -n B --clone A
一般来说,用pip install就行了,至于conda install与其有什么区别,详见博客[传送门]
- # 安装项目requirements.txt文件依赖:
- pip install -r requirements.txt
- # 生成requirements.txt文件:
- pip freeze > requirements.txt
注意!安装torch和torchvision时,两者之间存在依赖关系,版本需要对应起来,参考博客[传送门]
如果在创建虚拟环境时出现以下报错:
- Solving environment: failed
-
- CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/noarch/repodata.json.bz2>
- Elapsed: -
-
- An HTTP error occurred when trying to retrieve this URL.
- HTTP errors are often intermittent, and a simple retry will get you on your way.
-
- If your current network has https://www.anaconda.com blocked, please file
- a support request with your network engineering team.
-
- SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'ssl3_get_server_certificate\', \'certificate verify failed\')])")))'))
解决方法:关闭SSL认证。输入以下指令即可:
conda config --set ssl_verify false
例如安装CLIP的时候出现以下报错:
- Obtaining clip from git+https://github.com/openai/CLIP.git@main#egg=clip (from -r requirements.txt (line 25))
- Cloning https://github.com/openai/CLIP.git (to revision main) to ./src/clip
- Running command git clone --filter=blob:none --quiet https://github.com/openai/CLIP.git /home/jst/code/instruct-pix2pix-main/src/clip
- fatal: unable to access 'https://github.com/openai/CLIP.git/': Failed to connect to github.com port 443 after 131058 ms: Connection timed out
- error: subprocess-exited-with-error
-
- × git clone --filter=blob:none --quiet https://github.com/openai/CLIP.git /home/jst/code/instruct-pix2pix-main/src/clip did not run successfully.
- │ exit code: 128
- ╰─> See above for output.
-
- note: This error originates from a subprocess, and is likely not a problem with pip.
- error: subprocess-exited-with-error
-
- × git clone --filter=blob:none --quiet https://github.com/openai/CLIP.git /home/jst/code/instruct-pix2pix-main/src/clip did not run successfully.
- │ exit code: 128
- ╰─> See above for output.
-
- note: This error originates from a subprocess, and is likely not a problem with pip.

解决方法(当然,切换成清华源也可以):
进入CLIP的GitHub网址,先将CLIP下载到本地,即点击下图中的Download ZIP,将该压缩包上传到服务器后进行解压,得到文件夹CLIP-main。
打开Anaconda,激活虚拟环境,在虚拟环境下进入文件夹CLIP-main,然后再输入以下指令进行clip包的安装:
pip install .
或者,直接将原来的指令拆解成下列指令,在服务器终端执行:
- git clone https://github.com/openai/CLIP.git
- cd CLIP
- pip install .
在使用到huggingface时,下载连接不稳定导致ConnectError
使用镜像网站链接解决稳定性问题,可使用以下方法改变huggingface网址,在命令行中设置环境变量:
HF_ENDPOINT=https://hf-mirror.com python xxx.py
1. 进入root模式(超级用户):
sudo su
2.任意路径执行命令:
- # 添加用户jst
- adduser jst
3.设置登录密码:
- # jst为前面注册的用户名(注意这里输入密码不回显)
- passwd jst
- # 后续若要更改密码,登录jst用户后,输入以下指令即可
- passwd
创建的新用户会在
home
目录下生成一个该用户名命名的文件夹。
- # 切换到root
- sudo su
- # jst为已注册的用户名
- userdel -r jst
- # 切换到root
- sudo su
- # jst是待授予权限的用户名,重启后生效
- usermod -aG sudo jst
将服务器1的文件夹/home/jst/1全部传输至服务器2的/home/jst/code/2/路径下:
- scp -P 22 -r /home/jst/1 jst@192.168.1.103:/home/jst/code/2/
- # 注意,-P要改成服务器192.168.1.103的端口号,此处为22
常用可选参数:
- -B 使用批处理模式(传输过程中不询问传输口令或短语)
- -C 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
- -p 保留原文件的修改时间,访问时间和访问权限。
- -r 递归复制整个目录。
- -P port 注意是大写的P, port是指定数据传输用到的端口号
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。