问题:本人在autodl上保存的环境因为很长时间没有开机,autodl竟然给我删除了。后来看了官网的介绍我才发现,原来15天不开机,autodl就会自动释放实例。
因此,我就自己重新选了一个虚拟环境,从头开始配置。
GPU的选择随便,我选择的镜像是
我先默认该GPU配置了python3.8的解释器。但是问题就出在这里,我通过pycharm寻找/root/miniconda3/bin
文件夹下的解释器时,没有找到python3.8的解释器。
只有python3.1 和3.12的解释器。没有安装python3.8
既然这样,那只能从头开始自己创建了。
我们现在xshell中,输入
conda env list
我们发现,只有base 这一个环境。
因此,我们需要创建自己的新的环境,在新的环境中跑代码。
首先在xshell中,输入
conda create -n py39 python=3.9
等待py39的环境自动创建好。这个时候,咱们先关掉xshell,然后重新打开xshell。输入
conda activate py39
如果出现这个错误CondaError: Run 'conda init' before 'conda activate'
解决方法:
第一步:确保初始化(如果之前做过,再做一次也无妨)
conda init bash
第二步:立即加载配置(最关键的一步!)
运行这个命令,它会告诉您当前的终端去重新读取一下配置文件,这样就能认识 conda activate 了。
source ~/.bashrc
第三步:现在,激活 py39 环境
conda activate py39
然后运行以下命令,查看当前路径:
pwd
pwd 是 “Print Working Directory” 的缩写。输出通常会是 /root 或者类似的主目录。请记住这个路径,我们所有的操作都在这里进行。
在该路径下,创建requirement.txt
,将准备安装的python包安装在py39这个新建的环境中。
requirement.txt 放在这里
requirement.txt
入下:
absl-py==2.1.0
anyio==4.4.0
archspec==0.2.3
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
async-lru==2.0.4
attrs==23.2.0
Babel==2.15.0
beautifulsoup4==4.12.3
bleach==6.1.0
boltons==23.0.0
Brotli==1.0.9
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==2.0.4
comm==0.2.2
contourpy==1.2.1
cryptography==42.0.5
cycler==0.12.1
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
distro==1.9.0
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.14.0
fonttools==4.53.0
fqdn==1.5.1
fsspec==2024.5.0
grpcio==1.64.0
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
ipykernel==6.29.4
ipython==8.25.0
ipywidgets==8.1.3
isoduration==20.11.0
jedi==0.19.1
Jinja2==3.1.4
json5==0.9.25
jsonpatch==1.33
jsonpointer==2.1
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter_server==2.14.1
jupyter_server_terminals==0.5.3
jupyterlab==4.2.1
jupyterlab-language-pack-zh-CN==4.2.post1
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.2
jupyterlab_widgets==3.0.11
kiwisolver==1.4.5
Markdown==3.6
MarkupSafe==2.1.5
matplotlib==3.9.0
matplotlib-inline==0.1.7
mistune==3.0.2
mpmath==1.3.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
networkx==3.3
notebook_shim==0.2.4
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.5.40
nvidia-nvtx-cu12==12.1.105
overrides==7.7.0
packaging==23.2
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
pillow==10.3.0
pip==24.0
platformdirs==3.10.0
pluggy==1.0.0
prometheus_client==0.20.0
prompt_toolkit==3.0.45
protobuf==5.27.0
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
Pygments==2.18.0
pyparsing==3.1.2
PySocks==1.7.1
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
PyYAML==6.0.1
pyzmq==26.0.3
referencing==0.35.1
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.18.1
ruamel.yaml==0.17.21
Send2Trash==1.8.3
setuptools==69.5.1
six==1.16.0
sniffio==1.3.1
soupsieve==2.5
stack-data==0.6.3
supervisor==4.2.5
sympy==1.12.1
tensorboard==2.16.2
tensorboard-data-server==0.7.2
terminado==0.18.1
tinycss2==1.3.0
torch==2.1.0+cu121
torchvision==0.18.0+cu121
tornado==6.4
tqdm==4.66.2
traitlets==5.14.3
truststore==0.8.0
types-python-dateutil==2.9.0.20240316
typing_extensions==4.12.1
uri-template==1.3.0
urllib3==2.1.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.8.0
Werkzeug==3.0.3
wheel==0.43.0
widgetsnbextension==4.0.11
zstandard==0.22.0
现在,因为文件就在当前目录,我们可以放心地执行安装命令了:
pip install -r requirement.txt
如果出现以下错误,可以直接无视
ERROR: Ignored the following versions that require a different python version: 1.2.0 Requires-Python >=3.9; 1.2.1 Requires-Python >=3.9; 1.2.1rc1 Requires-Python >=3.9; 1.3.0 Requires-Python >=3.9; 1.3.1 Requires-Python >=3.10; 1.3.2 Requires-Python >=3.10; 1.3.3 Requires-Python >=3.11; 2.0.0b1 Requires-Python >=3.9; 2.0.5 Requires-Python >=3.9; 25.1.0 Requires-Python >=3.9; 4.10.0 Requires-Python >=3.9; 4.6.0 Requires-Python >=3.9; 4.6.1 Requires-Python >=3.9; 4.6.2.post1 Requires-Python >=3.9; 4.7.0 Requires-Python >=3.9; 4.8.0 Requires-Python >=3.9; 4.9.0 Requires-Python >=3.9; 6.2.0 Requires-Python >=3.9ERROR: Could not find a version that satisfies the requirement contourpy==1.2.1 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.1.0, 1.1.1rc1, 1.1.1)ERROR: No matching distribution found for contourpy==1.2.1
最重要的一步来了,pycharm中配置python39解释器的路径在:
还有,记得,如果pycharm中出现让你安装不满足要求的包,一定要让pycharm帮你安上!