rstudio / tensorflow

TensorFlow for R
https://tensorflow.rstudio.com
Apache License 2.0
1.33k stars 318 forks source link

Attempting to perform BLAS operation using StreamExecutor without BLAS support #512

Closed drdataking closed 2 months ago

drdataking commented 2 years ago

I am trying the beginners' tutorial but have the following errors when I fit the model. I appreciate if you could help me. Thank you.

2022-02-21 08:44:09.486498: E tensorflow/stream_executor/cuda/cuda_blas.cc:226] **failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED**
2022-02-21 08:44:09.486805: W tensorflow/core/framework/op_kernel.cc:1745] **OP_REQUIRES failed at matmul_op_impl.h:442 : INTERNAL: Attempting to perform BLAS operation using StreamExecutor without BLAS support**

to add: everything works fine under Python

The following is the output from each code until the error.

> library(tensorflow)
> tf$constant("Hellow Tensorflow")

2022-02-21 08:40:16.264035: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-02-21 08:40:16.903075: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2779 MB memory:  -> device: 0, name: Quadro P1000, pci bus id: 0000:c1:00.0, compute capability: 6.1
tf.Tensor(b'Hellow Tensorflow', shape=(), dtype=string)

> library(keras)
> mnist <- dataset_mnist()
> mnist$train$x <- mnist$train$x/255
> mnist$test$x <- mnist$test$x/255
> model <- keras_model_sequential() %>% 
     layer_flatten(input_shape = c(28, 28)) %>% 
     layer_dense(units = 128, activation = "relu") %>% 
     layer_dropout(0.2) %>% 
     layer_dense(10, activation = "softmax")
> summary(model)

Model: "sequential"

 Layer (type)                                                      Output Shape                                               Param  #               

 flatten (Flatten)                                                 (None, 784)                                                0                      

 dense_1 (Dense)                                                   (None, 128)                                                100480                 

 dropout (Dropout)                                                 (None, 128)                                                0                      

 dense (Dense)                                                     (None, 10)                                                 1290                   

=====================================================================================================================================================
Total params: 101,770
Trainable params: 101,770
Non-trainable params: 0
_____________________________________________________________________________________________________________________________________________________
> model %>% 
     compile(
         loss = "sparse_categorical_crossentropy",
         optimizer = "adam",
         metrics = "accuracy"
     )
> model %>% 
     fit(
         x = mnist$train$x, y = mnist$train$y,
         epochs = 5,
         validation_split = 0.3,
         verbose = 2
     )

2022-02-21 08:44:09.486498: E tensorflow/stream_executor/cuda/cuda_blas.cc:226] **failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED**
2022-02-21 08:44:09.486805: W tensorflow/core/framework/op_kernel.cc:1745] **OP_REQUIRES failed at matmul_op_impl.h:442 : INTERNAL: Attempting to perform BLAS operation using StreamExecutor without BLAS support**
 Error in py_call_impl(callable, dots$args, dots$keywords) : 
InternalError: Attempting to perform BLAS operation using StreamExecutor without BLAS support
[[node sequential/dense_1/MatMul
(defined at C:\PROGRA~3\ANACON~1\lib\site-packages\keras\layers\core\dense.py:199)
]] [Op:__inference_train_function_620]

Errors may have originated from an input operation.
Input Source operations connected to node sequential/dense_1/MatMul:
In[0] sequential/flatten/Reshape (defined at C:\PROGRA~3\ANACON~1\lib\site-packages\keras\layers\core\flatten.py:96)    
In[1] sequential/dense_1/MatMul/ReadVariableOp:

Operation defined at: (most recent call last)
>>> File "C:\PROGRA~3\ANACON~1\lib\site-packages\keras\utils\traceback_utils.py", line 64, in error_handler
>>> return fn(*args, **kwargs)
>>> 
>>> File "C:\PROGRA~3\ANACON~1\lib\site-packages\keras\engine\training.py", line 1216, in fit
>>> tmp_logs = self.train_function(iterator)
>>> 
>>> File "C:\PROGRA~3\ANACON~1\lib\site-packages\keras\engine\training.py", line 878, in train_functi
andrearlotta commented 6 months ago

Hi there! Did you succeed?

t-kalinowski commented 6 months ago

From your traceback, it appears that you installed tensorflow through anaconda, and are attempting to use the GPU on windows. We recommend installing tensorflow through pip into a virtualenv (done for you if you call the R function tensorflow::install_tensorflow().

Also, GPU usage by TensorFLow on windows is only supported if being used from WSL.

Please install tensorflow using tensorflow::install_tensorflow(), and if you are still encountering the error, please post the output from tensorflow::install_tensorflow() and reticulate::py_config().

github-actions[bot] commented 2 months ago

Automatically closed because there has not been a response for 30 days. When you're ready to work on this further, please comment here and the issue will automatically reopen.