安装miniconda3

使用yay安装软件包

yay -S miniconda3

将miniconda添加到命令行环境变量

echo "[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc
echo "[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh" >> ~/.zshrc

设置.condarc配置文件

在用户文件夹根目录创建.condarc文件,例如/home/chocola/.condarc,文件内容如下:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

envs_dirs:
  - /run/media/chocola/6T-DATA/Python_Files/Python_envs/


pkgs_dirs:
  - /run/media/chocola/6T-DATA/Python_Files/conda_cache/

show_channel_urls: true

其中channels:是软件源,envs_dirs:是环境安装的路径,pkgs_dirs:是下载缓存的路径。

部署环境

尝试部署一个名称为stable_diffusionpython3.9环境:

conda create --name stable_diffusion python=3.9

如果遇到这个报错RuntimeError: OpenSSL 3.0's legacy provider failed to load. This is a fatal error by default, but cryptography supports running without legacy algorithms by setting the environment variable CRYPTOGRAPHY_OPENSSL_NO_LEGACY. If you did not expect this error, you have likely made a mistake with your OpenSSL configuration.
这个错误是由于cryptography库与OpenSSL 3.0的兼容性问题引起的。
通过设置环境变量CRYPTOGRAPHY_OPENSSL_NO_LEGACY来允许cryptography库在不使用OpenSSL的遗留算法的情况下运行。
执行下面的命令:

export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1

运行后即可正常部署环境。

激活/取消激活环境:

激活环境:

conda activate stable_diffusion

取消激活:

conda deactivate