{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compile StyleForge CUDA Kernels\n", "\n", "Run this notebook in Google Colab to compile the CUDA kernels and download them for deployment to Hugging Face Spaces." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Check if GPU is available\n", "!nvidia-smi" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Clone the repository\n", "!git clone https://github.com/olivialiau/StyleForge\n", "%cd StyleForge/huggingface-space" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The PyTorch with CUDA should already be installed in Colab\n", "import torch\n", "print(f'PyTorch: {torch.__version__}')\n", "print(f'CUDA available: {torch.cuda.is_available()}')\n", "if torch.cuda.is_available():\n", " print(f'CUDA version: {torch.version.cuda}')\n", " print(f'GPU: {torch.cuda.get_device_name(0)}')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install ninja for compilation\n", "!pip install ninja -q" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run the compilation script\n", "!python compile_kernels.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# List the compiled kernels\n", "!ls -lh kernels/prebuilt/" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Download the compiled kernels\n", "from google.colab import files\n", "import pathlib\n", "\n", "prebuilt_dir = pathlib.Path('kernels/prebuilt')\n", "kernel_files = list(prebuilt_dir.glob('*.so')) + list(prebuilt_dir.glob('*.pyd'))\n", "\n", "if kernel_files:\n", " for f in kernel_files:\n", " print(f'Downloading: {f.name}')\n", " files.download(str(f))\n", "else:\n", " print('No kernel files found!')\n", " print('Check the compilation output above for errors.')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.10.0" } }, "nbformat": 4, "nbformat_minor": 4 }