Skip to content

Instantly share code, notes, and snippets.

@pmbaumgartner
Last active January 7, 2022 00:52
Show Gist options
  • Save pmbaumgartner/937282d78f113dcb2cca88f2cab5a8cc to your computer and use it in GitHub Desktop.
Save pmbaumgartner/937282d78f113dcb2cca88f2cab5a8cc to your computer and use it in GitHub Desktop.
Install spaCy with correct cuda version on Colab with GPU
# SETUP
cuda_version = !nvcc --version | grep -Po '^.*release \K([0-9]+\.[0-9])' | sed 's/\.//g'
# REQUIREMENTS
from pathlib import Path
reqs = f"""
spacy[cuda{cuda_version.s},transformers,lookups]==3.2.1
"""
Path("requirements.txt").write_text(reqs)
!pip install --quiet -r requirements.txt
# Check GPU is available
import spacy
assert spacy.require_gpu()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment