Install the unsloth
package, and make your Conda environment available as a kernel in Jupyter, on a system running WSL2 on Windows 11 with an Nvidia 40XX GPU.
First, download and install Mambaforge:
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
bash Mambaforge-Linux-x86_64.sh
Create a new Conda environment named unsloth_env
with Python 3.10:
mamba create --name unsloth_env python=3.10
mamba activate unsloth_env
Install the necessary packages including pytorch
, cudatoolkit
, xformers
, and bitsandbytes
:
mamba install cudatoolkit xformers bitsandbytes pytorch pytorch-cuda=12.1 -c pytorch -c nvidia -c xformers -c conda-forge
Upgrade pip
to the latest version to avoid installation issues:
pip install --upgrade pip
Install the unsloth
package from the GitHub repository:
pip install "unsloth[conda] @ git+https://github.com/unslothai/unsloth.git"
Install ipykernel
and add the Conda environment as a kernel in Jupyter:
mamba install ipykernel
python -m ipykernel install --user --name=unsloth_env --display-name "Python (unsloth_env)"
Check if the kernel is successfully added to Jupyter:
jupyter kernelspec list
Start Jupyter Notebook or JupyterLab to use the newly added kernel:
jupyter notebook
or
jupyter lab
If you encounter the following error:
ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/drusniel/mambaforge/envs/unsloth_env/lib/python3.10/site-packages/pkg_resources/__init__.py)
You can resolve it by installing a specific version of setuptools
using Mamba: (version 70 didn't work)
mamba install setuptools==69.5.1
If you encounter the following error:
ValueError: Query/Key/Value should all have BMHK or BMK shape.
- Operating System: Windows 11 with WSL2
- GPU: Nvidia 40XX
By following these steps, I was able to set up my environment, install the necessary packages, and configure the Jupyter kernel correctly.