pythongpuspacyspacy-transformers

Installing Spacy for GPU training of Transformer


I installed also the CudaToolkit, and cuDNN.

I have the following

GPU:
| NVIDIA-SMI 531.68                 Driver Version: 531.68       CUDA Version: 12.1     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                      TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3070 T...  WDDM | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P8                9W /  N/A|      0MiB /  8192MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

I have been trying to install spacy with the following instructions on a couple of posts on the site and used

pip install spacy[cuda121]

I get a warning that spacy 3.5.2 does not detect or support CUDA version 12.1.

I manage to get tensorflow to detect the GPU and when I run the following:

import tensorflow as tf
print('Num GPUs Available: ', len(tf.config.list_physical_devices('GPU')))

It detects 1 GPU. I also ran:

pip install cudy

I am wondering if there is something wrong with setup or if I doing something wrong. Any support would be much appreciated.


Solution

  • After reading the installation documentation and seeing the warning that you got, it seems that spaCy does not currently support CUDA 12.1. The installation guide is misleading because you can select the version of CUDA and there is a version for CUDA 10.2, 11.0+. Which suggests that anything above 11.0 is supported. However, that is not the case.

    Here is what I mean by the installation guide being misleading: enter image description here

    Your best bet would be to downgrade your version of CUDA to CUDA 11.8. If you're looking for the CUDA 11.8 links on the nvidia website:

    Here is a GitHub discussion that talks about which version of CUDA should be used with both spaCy and pytorch after the release of CUDA 12.1: