Win10下R环境中TensorFlow/Keras GPU版本安装报错求助
Alright, let's work through this step by step to get TensorFlow/Keras GPU version up and running on your Win10 system with the Nvidia GeForce MX150. I’ve tackled similar issues before, so here’s a structured approach to fix both the AVX2 warning and the conda installation error:
The MX150 supports CUDA, but we need to stick to TensorFlow versions that work with its compute capability (6.1). Newer TF versions (2.11+) dropped support for older GPUs like yours, so we’ll target TensorFlow 2.10 GPU—it’s the last compatible build.
- Download and install the latest stable Nvidia driver for MX150 (skip this if you already have up-to-date drivers). Reboot your system after installation to apply changes.
TensorFlow GPU relies on CUDA and cuDNN, and their versions must align perfectly with the TF version we’re using. For TF 2.10:
- CUDA Toolkit 11.2: Download and install this specific version (not the latest). Choose the "Custom" installation option and ensure all CUDA-related components (Runtime, Development Tools) are checked.
- cuDNN 8.1.0 for CUDA 11.2: Grab this from Nvidia’s developer portal (you’ll need a free account to download). Extract the zip file, then copy the
bin,include, andlibfolders into your CUDA installation directory (usuallyC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2).
Windows needs to know where CUDA and cuDNN are located:
- Open System Properties > Advanced > Environment Variables.
- Under System Variables:
- Add a new variable
CUDA_PATHwith the valueC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2 - Add another variable
CUDNN_PATHwith the same value as above - Edit the
Pathvariable and add these entries:%CUDA_PATH%\bin%CUDA_PATH%\libnvvp%CUDNN_PATH%\bin
- Add a new variable
- Reboot your PC to make sure these variables take effect.
The existing r-tensorflow environment might have conflicts, so let’s wipe it first:
library(reticulate) conda_remove(envname = "r-tensorflow")
If this throws an error, you can manually delete the environment folder at C:\Users\[Your Username]\.conda\envs\r-tensorflow.
Now install the compatible GPU build using conda:
library(tensorflow) install_tensorflow(version = "2.10-gpu", envname = "r-tensorflow", method = "conda")
- The
2.10-gputag ensures we get the GPU-optimized version that works with your MX150. - Specifying
method = "conda"ensures we use a clean conda environment.
Once installation finishes, test if TensorFlow recognizes your GPU:
library(tensorflow) tf$config$list_physical_devices("GPU")
If you see an entry for your MX150, you’re all set! You can also test Keras quickly:
library(keras) test_model <- keras_model_sequential() %>% layer_dense(units = 8, input_shape = c(8))
If this runs without errors, the GPU version is working correctly.
If you still hit that error during installation, try these fixes:
- Run R/RStudio as Administrator: Permission issues often block conda from installing packages. Right-click RStudio and select "Run as administrator" before running the install command.
- Check Conda Installation: Make sure conda is in your system PATH. Open Command Prompt and run
conda --version—if it’s not recognized, install Miniconda (64-bit) and ensure you check the "Add to PATH" option during setup. - Clear Conda Cache: Open Command Prompt and run
conda clean --allto delete cached packages, then retry the R installation command. - Disable Antivirus Temporarily: Some antivirus tools block conda’s package downloads. Turn it off briefly during installation, then re-enable it.
Once you switch to the GPU version, this warning should disappear automatically—TensorFlow will prioritize using your MX150 over the CPU. If it still pops up, you can suppress it with this line at the start of your scripts:
library(tensorflow) tf$compat$v1$logging$set_verbosity(tf$compat$v1$logging$ERROR)
内容的提问来源于stack exchange,提问作者Grec001

