Anaconda配置Python3.6+TensorFlow1.12.0+Keras(CPU/GPU版)离线/在线指南

需积分: 47 32 下载量 32 浏览量 更新于2023-03-16 2 收藏 298KB DOCX 举报
"本资源详细介绍了如何在有网络和无网络的情况下,利用anaconda在CPU和GPU环境下配置python3.6、tensorflow1.12.0以及keras。" 在anaconda环境中配置python3.6、tensorflow1.12.0和keras,无论是在连网还是离线的电脑上,都需要遵循一定的步骤。首先,确保安装了anaconda3,这可以通过执行exe安装文件并按照提示操作来完成,记得在安装过程中选择添加环境变量。对于连网的电脑,配置基于CPU的tensorflow时,需要安装Visual C++(VC),然后安装python。之后,通过anaconda prompt创建一个新环境,指定python版本为3.6。 在新环境中,使用命令行安装tensorflow和keras。对于keras的安装,需要切换到特定的文件路径下执行安装。安装完成后,通过重新打开anaconda prompt并运行相关命令来验证安装是否成功。 如果要配置基于GPU的tensorflow,除了上述步骤外,还需要安装CUDA和CUDNN。CUDA的安装是通过执行两个exe文件,而CUDNN则需要解压缩后将文件复制到指定的CUDA目录下。然后,使用GPU版本的tensorflow安装命令进行安装,验证步骤与CPU环境相同。 对于离线电脑,所有需要的安装包都必须提前准备好并拷贝到电脑上。例如,anaconda3的安装包、python的exe文件、以及tensorflow和keras的whl文件等。离线安装时,先安装anaconda,然后将环境文件拷贝到envs目录下,激活环境并进行相应的安装。同样,离线安装GPU版本的tensorflow也需要提前准备CUDA和CUDNN的安装文件,按照类似步骤进行安装。 在所有安装步骤完成后,可以通过运行python环境、检查tensorflow和keras的版本来验证配置是否成功。成功后,可以启动如spyder这样的IDE进行开发工作。无论是在线还是离线环境,关键在于正确安装和配置各个依赖,并确保它们在anaconda环境中能正常运行。

/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/gym/core.py:27: UserWarning: WARN: Gym minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+ "Gym minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+" Traceback (most recent call last): File "run_re2.py", line 81, in <module> parameters = Parameters(parser) # Inject the cla arguments in the parameters object File "/home/zhangmengjie/PID/Python/ERL-Re2-main/parameters.py", line 117, in __init__ self.wandb = wandb.init(project="TSR",name=self.name) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_init.py", line 1173, in init raise e File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_init.py", line 1150, in init wi.setup(kwargs) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_init.py", line 172, in setup self._wl = wandb_setup.setup(settings=setup_settings) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_setup.py", line 327, in setup ret = _setup(settings=settings) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_setup.py", line 320, in _setup wl = _WandbSetup(settings=settings) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_setup.py", line 303, in __init__ _WandbSetup._instance = _WandbSetup__WandbSetup(settings=settings, pid=pid) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_setup.py", line 108, in __init__ self._settings = self._settings_setup(settings, self._early_logger) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_setup.py", line 128, in _settings_setup s._apply_env_vars(self._environ, _logger=early_logger) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_settings.py", line 1597, in _apply_env_vars self.update(env, source=Source.ENV) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_settings.py", line 1453, in update self.__dict__[key].update(settings.pop(key), source=source) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_settings.py", line 425, in update self._value = self._validate(self._preprocess(value)) File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_settings.py", line 386, in _validate if not v(value): File "/home/zhangmengjie/anaconda3/envs/torch/lib/python3.6/site-packages/wandb/sdk/wandb_settings.py", line 898, in _validate_mode raise UsageError(f"Settings field `mode`: {value!r} not in {choices}") wandb.errors.UsageError: Settings field `mode`: '' not in {'online', 'run', 'dryrun', 'disabled', 'offline'}

2023-07-22 上传