Python环境检测,人工智能编程环境
天池 |
|
Python环境检测 |
|
# 1.1 系统 & 硬件 !uname -a # OS / 内核 !lscpu | head -10 # CPU 型号 & 核数 !free -h # 内存 !df -h | grep '/' # 磁盘剩余 !nvidia-smi 2>/dev/null || echo "No GPU" # GPU 型号 / 显存 # 1.2 预装软件版本 !python --version !python3 --version !pip --version !git --version !which gcc && gcc --version # 编译器 # 1.3 网络连通性(可选) !ping -c 2 gitee.com Linux dsw-536437-89dcd8865-mzwzh 4.19.91-012.ali4000.alios7.x86_64 #1 SMP Wed Sep 15 17:27:09 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
架构: x86_64
CPU 运行模式: 32-bit, 64-bit
字节序: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU: 32
在线 CPU 列表: 0-31
每个核的线程数: 2
每个座的核数: 16
座: 1
NUMA 节点: 1
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 6.0Gi 477Mi 5.2Gi 0B 368Mi 5.5Gi
交换: 0B 0B 0B
overlay 492G 117G 355G 25% /
tmpfs 64M 0 64M 0% /dev
tmpfs 62G 0 62G 0% /sys/fs/cgroup
/dev/vda2 492G 117G 355G 25% /tmp
shm 64M 0 64M 0% /dev/shm
overlay 492G 117G 355G 25% /etc/dsw
tmpfs 124G 12K 124G 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 62G 0 62G 0% /proc/acpi
tmpfs 62G 0 62G 0% /proc/scsi
tmpfs 62G 0 62G 0% /sys/firmware
No GPU
Python 3.7.13
Python 3.7.13
pip 24.0 from /opt/conda/lib/python3.7/site-packages/pip (python 3.7)
git version 2.25.1
/usr/bin/gcc
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/bin/bash: ping:未找到命令
|
|
import sys, os, platform, subprocess, pkg_resources, psutil, torch
print("=" * 60)
print("🔍 Python 运行环境")
print("=" * 60)
print("Python:", sys.version)
print("Platform:", platform.platform())
print("PWD:", os.getcwd())
print("=" * 60)
# 2.1 关键库版本
libs = ["torch", "transformers", "accelerate", "sentencepiece", "modelscope"]
for lib in libs:
try:
ver = pkg_resources.get_distribution(lib).version
print(f"{lib:<15} {ver}")
except:
print(f"{lib:<15} ❌ 未安装")
# 2.2 硬件资源
mem = psutil.virtual_memory()
print("\n🔍 资源快照")
print(f"Memory Total : {mem.total/1024**3:.1f} GB")
print(f"Memory Free : {mem.available/1024**3:.1f} GB")
print(f"GPU Available : {torch.cuda.is_available()}")
if torch.cuda.is_available():
for i in range(torch.cuda.device_count()):
print(f" - GPU {i} : {torch.cuda.get_device_name(i)} "
f"{torch.cuda.memory_reserved(i)/1024**3:.1f} GB")
print("=" * 60)
============================================================ 🔍 Python 运行环境 ============================================================ Python: 3.7.13 (default, Mar 29 2022, 02:18:16) [GCC 7.5.0] Platform: Linux-4.19.91-012.ali4000.alios7.x86_64-x86_64-with-debian-bullseye-sid PWD: /mnt/workspace ============================================================ torch 1.11.0+cpu transformers 4.24.0 accelerate 0.20.3 sentencepiece 0.1.97 modelscope 1.28.1 🔍 资源快照 Memory Total : 6.0 GB Memory Free : 5.5 GB GPU Available : False ============================================================
def llm_ready(): ok = True if sys.version_info < (3, 7): print("❌ Python 版本过低,建议 ≥3.8") ok = False if torch.__version__ < "1.10": print("⚠️ PyTorch 版本较低,可能影响性能") if not torch.cuda.is_available(): print("⚠️ 无 GPU,仅 CPU 推理,速度会慢") try: from transformers import AutoTokenizer, AutoModel print("✅ transformers 可用") except ImportError: print("❌ 未安装 transformers") ok = False return ok print("LLM 环境就绪?" , "✅ 可以跑" if llm_ready() else "❌ 需升级/安装") ⚠️ 无 GPU,仅 CPU 推理,速度会慢 ✅ transformers 可用 LLM 环境就绪? ✅ 可以跑
|
|
浙大平台
|
|
# 1.1 系统 & 硬件 !uname -a # OS / 内核 !lscpu | head -10 # CPU 型号 & 核数 !free -h # 内存 !df -h | grep '/' # 磁盘剩余 !nvidia-smi 2>/dev/null || echo "No GPU" # GPU 型号 / 显存 # 1.2 预装软件版本 !python --version !python3 --version !pip --version !git --version !which gcc && gcc --version # 编译器 # 1.3 网络连通性(可选) !ping -c 2 gitee.com Linux notebook 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
total used free shared buff/cache available
Mem: 187G 13G 150G 4.1G 23G 169G
Swap: 0B 0B 0B
overlay 503G 289G 215G 58% /
tmpfs 64M 0 64M 0% /dev
tmpfs 94G 0 94G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 35G 16G 70% /etc/hosts
/dev/mapper/centos-home 503G 289G 215G 58% /etc/hostname
shm 64M 0 64M 0% /dev/shm
10.203.10.174:/mnt/user_directory/68a555116eba6373f7fd90d3/68a55fe9b0a1e361589b21a3 28T 28T 411G 99% /home/jovyan/work
tmpfs 94G 12K 94G 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 94G 0 94G 0% /proc/acpi
tmpfs 94G 0 94G 0% /proc/scsi
tmpfs 94G 0 94G 0% /sys/firmware
No GPU
Python 3.7.5
Python 3.7.5
pip 21.1.3 from /home/jovyan/.virtualenvs/basenv/lib/python3.7/site-packages/pip (python 3.7)
git version 2.17.1
/usr/bin/gcc
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PING gitee.com-31ba39d0fd3.baiduads.com (180.76.199.13) 56(84) bytes of data.
--- gitee.com-31ba39d0fd3.baiduads.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms
|
|
import sys, os, platform, subprocess, pkg_resources, psutil, torch print("=" * 60) print("🔍 Python 运行环境") print("=" * 60) print("Python:", sys.version) print("Platform:", platform.platform()) print("PWD:", os.getcwd()) print("=" * 60) # 2.1 关键库版本 libs = ["torch", "transformers", "accelerate", "sentencepiece", "modelscope"] for lib in libs: try: ver = pkg_resources.get_distribution(lib).version print(f"{lib:<15} {ver}") except: print(f"{lib:<15} ❌ 未安装") # 2.2 硬件资源 mem = psutil.virtual_memory() print("\n🔍 资源快照") print(f"Memory Total : {mem.total/1024**3:.1f} GB") print(f"Memory Free : {mem.available/1024**3:.1f} GB") print(f"GPU Available : {torch.cuda.is_available()}") if torch.cuda.is_available(): for i in range(torch.cuda.device_count()): print(f" - GPU {i} : {torch.cuda.get_device_name(i)} " f"{torch.cuda.memory_reserved(i)/1024**3:.1f} GB") print("=" * 60) ============================================================ 🔍 Python 运行环境 ============================================================ Python: 3.7.5 (default, Dec 9 2021, 17:04:37) [GCC 8.4.0] Platform: Linux-3.10.0-1127.el7.x86_64-x86_64-with-Ubuntu-18.04-bionic PWD: /home/jovyan/work ============================================================ torch 1.8.1+cpu transformers 4.1.1 accelerate ❌ 未安装 sentencepiece 0.1.91 modelscope ❌ 未安装 🔍 资源快照 Memory Total : 187.4 GB Memory Free : 169.1 GB GPU Available : False ============================================================
|
|
def llm_ready(): ok = True if sys.version_info < (3, 7): print("❌ Python 版本过低,建议 ≥3.8") ok = False if torch.__version__ < "1.10": print("⚠️ PyTorch 版本较低,可能影响性能") if not torch.cuda.is_available(): print("⚠️ 无 GPU,仅 CPU 推理,速度会慢") try: from transformers import AutoTokenizer, AutoModel print("✅ transformers 可用") except ImportError: print("❌ 未安装 transformers") ok = False return ok print("LLM 环境就绪?" , "✅ 可以跑" if llm_ready() else "❌ 需升级/安装") ⚠️ 无 GPU,仅 CPU 推理,速度会慢 2025-08-20 13:47:59.415739: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory 2025-08-20 13:47:59.415772: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. ✅ transformers 可用 LLM 环境就绪? ✅ 可以跑
|
|
| XEdu | |
import sys, os, platform, subprocess, pkg_resources, psutil, torch print("=" * 60) print("🔍 Python 运行环境") print("=" * 60) print("Python:", sys.version) print("Platform:", platform.platform()) print("PWD:", os.getcwd()) print("=" * 60) # 2.1 关键库版本 libs = ["torch", "transformers", "accelerate", "sentencepiece", "modelscope"] for lib in libs: try: ver = pkg_resources.get_distribution(lib).version print(f"{lib:<15} {ver}") except: print(f"{lib:<15} ❌ 未安装") # 2.2 硬件资源 mem = psutil.virtual_memory() print("\n🔍 资源快照") print(f"Memory Total : {mem.total/1024**3:.1f} GB") print(f"Memory Free : {mem.available/1024**3:.1f} GB") print(f"GPU Available : {torch.cuda.is_available()}") if torch.cuda.is_available(): for i in range(torch.cuda.device_count()): print(f" - GPU {i} : {torch.cuda.get_device_name(i)} " f"{torch.cuda.memory_reserved(i)/1024**3:.1f} GB") print("=" * 60) ============================================================ 🔍 Python 运行环境 ============================================================ Python: 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] Platform: Windows-10-10.0.22621-SP0 PWD: D:\XEdu\人工智能 ============================================================ torch 2.4.1 transformers 4.46.3 accelerate 1.0.1 sentencepiece ❌ 未安装 modelscope 1.22.3 🔍 资源快照 Memory Total : 15.7 GB Memory Free : 0.3 GB GPU Available : False ============================================================
|
|
requirements.txt
|
|
absl-py==0.9.0 alembic==1.12.1 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 ase==3.21.1 astor==0.8.1 asttokens==2.4.1 astunparse==1.6.3 async-generator==1.10 attrs==19.3.0 Augmentor==0.2.8 backcall==0.2.0 baytune==0.4.0 bleach==5.0.0 blis==0.4.1 boto3==1.16.25 botocore==1.19.25 cachetools==3.1.1 cairocffi==1.3.0 CairoSVG==2.5.2 calysto==1.0.6 catalogue==1.0.0 certifi==2022.9.24 certipy==0.1.3 cffi==1.15.0 charset-normalizer==2.1.1 click==8.1.2 cloudpickle==1.2.2 cmake==3.21.1 configparser==5.2.0 copulas==0.3.3 cryptography==36.0.2 cssselect2==0.5.0 cycler==0.11.0 cymem==2.0.6 Cython==0.29.20 debugpy==1.6.0 decorator==4.4.2 defusedxml==0.7.1 distlib==0.3.4 dlib==19.22.0 dm-tree==0.1.7 easydict==1.9 en-core-web-sm @ https://files.momodel.cn/en_core_web_sm-2.3.0.tar.gz entrypoints==0.4 et-xmlfile==1.1.0 fastjsonschema==2.15.3 filelock==3.6.0 func-timeout==4.3.5 future==0.18.2 gast==0.3.3 gensim==3.8.3 google-auth==2.14.0 google-auth-oauthlib==0.4.6 google-pasta==0.2.0 googledrivedownloader==0.4 graphviz==0.14 greenlet==1.1.2 grpcio==1.29.0 gym==0.15.7 h5py==2.10.0 idna==3.4 imageio==2.8.0 imageio-ffmpeg==0.5.1 imbalanced-learn==0.6.2 imgaug==0.4.0 importlib-metadata==4.13.0 importlib-resources==5.7.0 ipdb==0.13.2 ipykernel==6.13.0 ipython==7.32.0 ipython-genutils==0.2.0 ipywidgets==7.4.0 isodate==0.6.1 jdcal==1.4.1 jedi==0.18.1 jieba==0.42.1 Jinja2==3.0.3 jmespath==0.10.0 joblib==1.1.0 jsonschema==4.4.0 jupyter-client==7.2.2 jupyter-core==4.9.2 jupyter-telemetry==0.1.0 jupyterhub==1.4.2 jupyterlab==1.0.0a1 jupyterlab-server==0.2.0 kanren==0.2.3 Keras==2.4.3 Keras-Preprocessing==1.1.2 kiwisolver==1.3.2 llvmlite==0.39.1 Mako==1.2.0 Markdown==3.4.1 MarkupSafe==2.1.1 matplotlib==3.0.3 matplotlib-inline==0.1.3 metakernel==0.29.0 mindspore @ https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp37-cp37m-linux_x86_64.whl minepy==1.2.4 minio==5.0.10 mistune==0.8.4 mock==5.2.0 moviepy==1.0.3 mpmath==1.2.1 multipledispatch==0.6.0 murmurhash==1.0.6 nbconvert==5.6.1 nbformat==5.3.0 nest-asyncio==1.5.5 networkx==2.6.3 nltk==3.5 notebook==6.2.0 numba==0.56.4 numexpr==2.8.6 numpy==1.18.5 numpyencoder==0.3.0 oauthlib==3.2.2 opencv-python==4.5.1.48 openpyxl==3.0.9 opt-einsum==3.3.0 packaging==21.3 paddlepaddle==2.0.1 pamela==1.0.0 pandas==1.3.5 pandocfilters==1.5.0 parso==0.8.3 pbr==5.8.1 pexpect==4.8.0 pickleshare==0.7.5 Pillow==8.1.0 plac==1.1.3 platformdirs==2.5.1 plotly==4.8.1 portpicker==1.3.9 preshed==3.0.6 proglog==0.1.10 prometheus-client==0.14.1 prompt-toolkit==3.0.29 protobuf==3.20.3 psutil==5.9.0 ptyprocess==0.7.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 PyAudio==0.2.11 pycparser==2.21 pydot==1.4.1 pyenchant==3.1.1 pygame==2.0.1 pyglet==1.5.0 Pygments==2.11.2 pyOpenSSL==22.0.0 pyparsing==3.0.7 pyrsistent==0.18.1 python-dateutil==2.8.2 python-json-logger==2.0.2 python-louvain==0.16 pytorch-pretrained-bert==0.6.2 pytorch-transformers==1.2.0 pytz==2022.1 PyWavelets==1.3.0 PyYAML==6.0 pyzmq==22.3.0 rdflib==6.3.2 regex==2022.3.15 requests==2.28.1 requests-oauthlib==1.3.1 retrying==1.3.3 rouge==1.0.0 rsa==4.9 ruamel.yaml==0.17.21 ruamel.yaml.clib==0.2.6 s3transfer==0.3.3 sacremoses==0.0.49 scikit-image==0.15.0 scikit-learn==0.22.2.post1 scipy==1.7.3 seaborn==0.10.1 semantic-version==2.8.5 Send2Trash==1.8.0 sentencepiece==0.1.91 Shapely==1.7.0 six==1.16.0 smart-open==5.2.1 spacy==2.3.2 SQLAlchemy==1.4.35 srsly==1.0.5 stevedore==3.5.0 svgwrite==1.4.2 sympy==1.6.2 tables==3.5.1 tensorboard==2.11.0 tensorboard-data-server==0.6.1 tensorboard-plugin-wit==1.8.1 tensorboardX==2.0 tensorflow==2.3.1 tensorflow-addons==0.11.2 tensorflow-estimator==2.3.0 tensorflow-federated==0.17.0 tensorflow-model-optimization==0.4.1 tensorflow-privacy==0.5.2 termcolor==2.1.1 terminado==0.13.3 testpath==0.6.0 tf-slim==1.1.0 thinc==7.4.1 tinycss2==1.1.1 tokenizers==0.9.4 toolz==0.11.2 torch @ https://download.pytorch.org/whl/cpu/torch-1.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl torch-geometric==1.7.0 torch-scatter @ https://data.pyg.org/whl/torch-1.8.0%2Bcpu/torch_scatter-2.0.8-cp37-cp37m-linux_x86_64.whl torch-sparse @ https://data.pyg.org/whl/torch-1.8.0%2Bcpu/torch_sparse-0.6.12-cp37-cp37m-linux_x86_64.whl torch-spline-conv @ https://data.pyg.org/whl/torch-1.8.0%2Bcpu/torch_spline_conv-1.2.1-cp37-cp37m-linux_x86_64.whl torchinfo==1.7.2 torchtext==0.6.0 torchvision @ https://download.pytorch.org/whl/cpu/torchvision-0.9.1%2Bcpu-cp37-cp37m-linux_x86_64.whl tornado==6.1 tqdm==4.46.1 traitlets==5.1.1 transformers==4.1.1 typeguard==2.13.3 typing-extensions==4.1.1 unification==0.2.2 urllib3==1.26.13 virtualenv==20.13.1 virtualenv-clone==0.5.7 virtualenvwrapper==4.7.0 wasabi==0.9.1 wcwidth==0.2.5 webencodings==0.5.1 Werkzeug==2.2.2 widgetsnbextension==3.4.2 word2vec==0.11.1 wrapt==1.14.1 xlrd==1.2.0 XlsxWriter==1.4.3 yellowbrick==1.1 zipp==3.11.0
|
|

浙公网安备 33010602011771号