OscarKjell / text

Using Transformers from HuggingFace in R
https://r-text.org
134 stars 30 forks source link

Unable to use GPU #178

Open SB427 opened 5 months ago

SB427 commented 5 months ago

Hi, I use the text package to do ZeroShot classification, and I have a lot of text, so I want to use my GPU, but it doesn't work. Here is my session info :

sessionInfo() R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22631) attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] torch_0.12.0 text_1.2.1 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.3 purrr_1.0.2
[8] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0 readr_2.1.5

When I ask torch is cuda is avalaible, it's true :

torch_tensor(1, device = "cuda") torch_tensor 1 [ CUDAFloatType{1} ] torch::cuda_is_available() [1] TRUE

And, when I run ZeroShot, I have this :

ZeroShot_test <- text::textZeroShot(sequences = test$text,

  • candidate_labels = c("programme de fidélité", "produit", "livraison", "arnaque"),
  • multi_label = TRUE,
  • model = "mtheo/camembert-base-xnli",
  • device="gpu",
  • tokenizer_parallelism = TRUE) [nltk_data] Downloading package punkt to [nltk_data] C:\Users\Super\AppData\Roaming\nltk_data... [nltk_data] Package punkt is already up-to-date! MPS for Mac available: False Unable to use MPS (Mac M1+), CUDA (GPU), using CPU

Could you help me ? Thanks a lot for your work !

OscarKjell commented 5 months ago

hi, thanks for the feedback.

have you tried having device = "mps", or device = "mps:0" or device = "mps:1"?

SB427 commented 5 months ago

Hello, I tried, and get the same message + MPS not available because the current PyTorch install was not built with MPS enabled.

Thanks.

SB427 commented 5 months ago

And I'm experiencing a new problem, my R session is disconnected any time I try to run the package text, and I really don(t understand what's going on...

OscarKjell commented 5 months ago

Have you tried running textrpp_install() since you updated the text version?

SB427 commented 5 months ago

Yes, this is the only function that works without crashing R... and this runs well.

OscarKjell commented 5 months ago

so, just to confirm, is it crashing when you run textrpp_initialize?

( it might be worth checking the GitHub action – and comparing your system with the Windows run that works... https://github.com/OscarKjell/text/actions/runs/8950248691 )

SB427 commented 5 months ago

Yes, it's crashing when I run textrpp_initialize. I will check the GitHub action. Thanks