問題:本人在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幫你安上!