Torch not compiled with CUDA enabled, need to use CUDA on my local PC

I'm trying to use my video card to analise some ML task.

I'm using this code:

import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("cointegrated/rubert-tiny2")
model = AutoModel.from_pretrained("cointegrated/rubert-tiny2")
model.cuda()  # uncomment it if you have a GPU

def embed_bert_cls(text, model, tokenizer):
    t = tokenizer(text, padding=True, truncation=True, return_tensors='pt')
    with torch.no_grad():
        model_output = model(**{k: v.to(model.device) for k, v in t.items()})
    embeddings = model_output.last_hidden_state[:, 0, :]
    embeddings = torch.nn.functional.normalize(embeddings)
    return embeddings[0].cpu().numpy()

and get this error:

AssertionError: Torch not compiled with CUDA enabled

I check my system and drivers and get this:

torch.cuda.is_available()

false

so i look in to version of torch:

torch.__version__

2.0.1+cpu

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Mon_Apr__3_17:36:15_Pacific_Daylight_Time_2023
Cuda compilation tools, release 12.1, V12.1.105
Build cuda_12.1.r12.1/compiler.32688072_0
nvidia-smi
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 531.68                 Driver Version: 531.68       CUDA Version: 12.1     |
|-----------------------------------------+----------------------+----------------------+

I wipe all my libs on pip and get fresh install from:

pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121/torch_stable.html

but still get 2.0.1+cpu version fo torch and cuda not available.

My OS is Windows 10 x64. I prefer not to use conda, only pip. I want to use my video card for ML analyse.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation