Skip to content

conda自建虚拟环境

更新: 12/21/2024 字数: 0 字 时长: 0 分钟

概述

由于一些项目安装构建比较复杂,故此记录

创建环境

  • 再当前目录创建env环境
bash
conda create -y -p .\env python=3.10

激活环境

bash
activate .\env

安装/更新依赖

bash
# 清除缓存
env\Scripts\pip.exe cache purge

# 安装
env\Scripts\pip.exe install --use-deprecated=legacy-resolver --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

检测环境

  • app.py
python

import torch

total_vram_in_gb = torch.cuda.get_device_properties(0).total_memory / 1073741824
print(f'\033[32mCUDA版本:{torch.version.cuda}\033[0m')
print(f'\033[32mPytorch版本:{torch.__version__}\033[0m')
print(f'\033[32m显卡型号:{torch.cuda.get_device_name()}\033[0m')
print(f'\033[32m显存大小:{total_vram_in_gb:.2f}GB\033[0m')
if torch.cuda.get_device_capability()[0] >= 8:
    print(f'\033[32mBF16支持:是\033[0m')
    dtype = torch.bfloat16
else:
    print(f'\033[32mBF16支持:否\033[0m')
    dtype = torch.float16
if torch.cuda.is_available():
        device = "cuda"
else:
    print("cuda not available, using cpu")
    device = "cpu"

常见问题

问题pydantic_core_schema

ERROR: Exception in ASGI application Traceback (most recent call last): File "/app/anaconda3/envs/digital_human/lib/python3.10/site-packages/pydantic/type_adapter.py", line 270, in _init_core_attrs self._core_schema = _getattr_no_parents(self._type, 'pydantic_core_schema') File "/app/anaconda3/envs/digital_human/lib/python3.10/site-packages/pydantic/type_adapter.py", line 112, in _getattr_no_parents raise AttributeError(attribute) AttributeError: pydantic_core_schema

  • AttributeError: ____解决通過fastapi降级
bash
env\Scripts\pip.exe install --use-deprecated=legacy-resolver --no-cache-dir fastapi==0.109.2

问题huggingface_hub报错

ImportError: cannot import name 'cached_download' from 'huggingface_hub'

bash
env\Scripts\pip.exe install --use-deprecated=legacy-resolver --no-cache-dir huggingface_hub==0.25.2

网站公告

说明

本站正在搭建并持续更新中,如果对您有帮助,不妨加入收藏

Last updated: