使用 Conda创建新的环境遇到的问题

下载速度很慢

1、更新

复制代码
conda update -n base -c defaults conda

2、清理缓存

复制代码
conda clean --all

解决方法

方法 1:关闭严格的渠道优先级
  1. 检查是否开启了严格渠道优先级:

    复制代码
    conda config --show channel_priority

    如果返回 strict,说明启用了严格的渠道优先级。

  2. 将渠道优先级改为 flexible:

    复制代码

    复制代码
    conda config --set channel_priority flexible

安装tensorflow(2.0版本以上不区分cpu和gpu版)

1. 更换国内镜像源

在中国大陆,直接连接到官方 PyPI 服务器可能会导致超时问题,推荐使用国内镜像源。以下是清华镜像的安装命令:

复制代码
pip install tensorflow==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

你也可以将镜像源永久配置到 pip 的配置文件中:

复制代码

复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

2. 设置更长的超时时间

网络环境较差时,可以尝试增加超时时间:

复制代码
pip install tensorflow==2.6.0 --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple

在命令行中直接检测 TensorFlow 是否安装成功,可以使用以下步骤:


1. 激活虚拟环境

如果你安装 TensorFlow 时使用的是虚拟环境(例如 tensorf_env),请先激活环境

复制代码

复制代码
conda activate tensorf_env

2. 使用 Python 检测 TensorFlow

在命令行中运行以下命令:

复制代码

复制代码
python -c "import tensorflow as tf; print(tf.__version__)"
  • 如果显示 TensorFlow 的版本号(例如 2.6.0),则说明安装成功。
  • 如果有错误信息,则说明安装有问题。

3. 检测 GPU 支持(可选)

如果需要检查是否检测到 GPU,可以运行以下命令:

复制代码

复制代码
python -c "import tensorflow as tf; print('GPU is', 'available' if tf.config.list_physical_devices('GPU') else 'NOT AVAILABLE')"
  • 如果输出 GPU is available,则说明安装的 TensorFlow 支持 GPU,且成功检测到 GPU。
  • 如果输出 GPU is NOT AVAILABLE,可能是显卡驱动、CUDA 或 cuDNN 未正确安装或未配置。
相关推荐
weixin_461769403 天前
conda create 创建容器 Failed to resolve ‘repo.anaconda.com‘问题
开发语言·python·conda·repo·网络问题·无法创建
饭来_7 天前
Ubuntu 中出现 CondaToSNonInteractiveError 的解决方法
ubuntu·conda·debug
emo_2b9 天前
Pycharm配置conda解释器时遇到的问题及解决方法
linux·pycharm·conda
Είναι η κοπέλα11 天前
llama.cpp 与 GGUF 格式:本地大模型的“裸引擎“
开发语言·人工智能·pytorch·python·conda
Είναι η κοπέλα13 天前
显存计算与模型选择:你的显卡能跑多大的模型
人工智能·pytorch·python·开源·conda
天蓝蓝的本我13 天前
conda日常用到的命令积累1-登录linux,安装pycharm
linux·pycharm·conda
Είναι η κοπέλα15 天前
Python 虚拟环境:venv、conda 与 Python 版本选择全解
开发语言·python·conda
夏天拐跑了西瓜17 天前
一文入门LangChain:从框架认知到构建你的第一个AI Agent
python·langchain·conda·agent
weixin_4617694018 天前
机械臂SDK运行日志
conda·sdk
三点水-here19 天前
从 Miniconda 迁移到 Miniforge3 全记录:安装、配置、环境迁移与排错实录
python·conda