Interactive topic maps from large text collections with cuML acceleration
Ensure the Hugging Face cache is writable so model downloads succeed on your hardware platform:
sudo chown -R $USER:$USER $HOME/.cache/huggingface 2>/dev/null || true
sudo chmod -R u+rwX $HOME/.cache/huggingface 2>/dev/null || true
mkdir -p $HOME/.cache/huggingface
If you see "Permission denied" when downloading models later, run the chown/chmod lines again for your user.
Create a new conda environment with RAPIDS libraries for GPU-accelerated data processing:
conda create -n rapids-25.10 \
-c rapidsai -c conda-forge \
cudf=25.10 cuml=25.10 python=3.11 'cuda-version=13.0'
This installs cuDF (GPU DataFrame library) and cuML (GPU machine learning library) that provide drop-in acceleration for pandas and scikit-learn operations.
conda activate rapids-25.10
Install UMAP, HDBSCAN, BERTopic, and supporting libraries for topic modeling.
Note: datamapplot will upgrade dask/distributed — the next command pins them back.
python -m pip install \
transformers datasets sentence-transformers \
umap-learn hdbscan==0.8.40 bertopic matplotlib \
scikit-learn==1.4.2 datamapplot streamlit "nbformat>=4.2.0" ipykernel
Register the conda environment as a Jupyter kernel:
python -m ipykernel install --user --name rapids-25.10 --display-name "Python (rapids-25.10)"
Pin dask/distributed back to RAPIDS-compatible versions:
python -m pip install "dask==2025.9.1" "distributed==2025.9.1"
These packages provide:
run_app.sh)NOTE
Pip may report dependency conflicts (for example, dask/distributed downgraded, or cuml/rapids-dask-dependency). BERTopic and the notebook can still run. If you need cuML and RAPIDS dask together, keep the conda default dask versions and install only the BERTopic stack via pip in a separate environment; see Troubleshooting.
Install JupyterLab and visualization libraries directly into the conda environment:
python -m pip install jupyterlab ipywidgets jupyterlab-widgets bokeh colorcet datashader plotly
Install PyTorch with CUDA 13.0 support for GPU-accelerated embedding generation:
python -m pip install torch==2.9.0 torchvision torchaudio==2.9.0 --index-url https://download.pytorch.org/whl/cu130
Clone the playbook repository and download the Amazon Electronics Reviews dataset:
git clone https://github.com/NVIDIA/dgx-spark-playbooks
cd dgx-spark-playbooks/nvidia/playbook-topic-modeling/assets
Download the dataset (~14 GB compressed):
wget https://mcauleylab.ucsd.edu/public_datasets/data/amazon_2023/raw/review_categories/Electronics.jsonl.gz
The notebook files are stored in Git LFS — without this step, JupyterLab will throw a NotJSONError when trying to open them.
conda install -c conda-forge git-lfs
git lfs install
git lfs pull
Start JupyterLab from the assets directory:
jupyter lab
NOTE
JupyterLab refuses to start as the root user and exits immediately with Running as root is not recommended. Use --allow-root to bypass. This happens, for example, when you enter WSL2 with wsl -d Ubuntu-24.04 -u root. Run the playbook as a regular (non-root) user, which is recommended. If you must stay as root, start JupyterLab with jupyter lab --allow-root.
Open a browser to the URL JupyterLab prints (typically http://localhost:8888). From another device, use http://<HARDWARE_IP>:8888 where <HARDWARE_IP> is your hardware platform's reachable address.
If you access the hardware platform over SSH, forward the Jupyter port to your local browser:
ssh -N -L YYYY:localhost:XXXX username@remote_host
YYYY: The local port you want to use (for example, 8888)XXXX: The port JupyterLab is listening on on the remote machine (for example, 8888)-N: Prevents SSH from executing a remote command-L: Specifies local port forwardingIn JupyterLab, open the notebook video_notebook_for_GPU_Accelerated_Machine_Learning_BERTopic_1M.ipynb.
Select the Python (rapids-25.10) kernel from the kernel selector in the top right corner of the notebook interface.
Run all cells in the notebook sequentially. The notebook will:
%load_ext cudf.pandas%load_ext cuml.accelAfter the notebook completes, you'll have:
As an alternative to the notebook, run the Streamlit dashboard for live UMAP/HDBSCAN tuning. From the assets directory (with the dataset already downloaded in Step 7):
chmod +x run_app.sh
./run_app.sh
Then open the URL it prints (default http://localhost:8501). The script auto-selects the rapids-25.10 conda env; override with PYTHON=/path/to/python ./run_app.sh if needed.
Remove the conda environment when finished:
conda deactivate
conda env remove -n rapids-25.10
Remove the downloaded dataset:
rm Electronics.jsonl.gz
Remove generated embedding files and the cloned playbook directory if you no longer need them:
# Optional: remove Hugging Face cache (embedding cache from the notebook)
rm -rf ~/.cache/huggingface
# From the parent of dgx-spark-playbooks/, remove the cloned repo
rm -rf dgx-spark-playbooks/
Apply this workflow to your own datasets:
nrows parameter when loading data to process smaller subsetsmin_cluster_size and min_samples in HDBSCANall-MiniLM-L6-v2 for domain-specific modelstopic_model.save() for later analysisnvidia-smi -l 1 to watch GPU utilization during processing