A template project combining Tauri, Python (TensorFlow), FastAPI, and Svelte to create lightweight desktop applications with integrated machine learning capabilities.
- 🖝 Tauri: Lightweight desktop application framework.
- 🧠 TensorFlow: Use Python to handle machine learning and AI tasks.
- 📡 TensorFlow-GPU: Using a version of TensorFlow with GPU capabilities for Windows.
- 🚀 FastAPI: High-performance API for backend communication.
- 📦 PyInstaller: Package Python applications into standalone executables.
- 🌟 Svelte: Build reactive and user-friendly UIs.
- 🔛 TypeScript Client: Auto-generated frontend client using
hey-api.
🗂 tauri-tensorflow-template
├── 🗁 server # Python TensorFlow + FastAPI backend
├── 🗁 src # Svelte frontend
├── 🗁 src-tauri # Rust-based Tauri application
└── 📄 README.md # Documentation
To enable GPU capabilities for TensorFlow, you must install the following NVIDIA components and add their paths to the system environment variables: Maybe try with only 12.6 and cudnn 9.6 first and if it doesn't work try with 11.8 and cudnn 8.9
After installation, ensure the following directories are added to your system's PATH environment variable:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\8.9.7\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin
C:\Program Files\NVIDIA\CUDNN\v9.6\bin
git clone https://github.com/ydubrana/tauri-tensorflow-template.git
cd tauri-tensorflow-templateUse Conda to create the required environment from the environment.yml file:
cd src-python
conda create --file environment.yml
conda activate tauri-tensorflowTo confirm the installation:
-
Open a terminal and run:
nvcc --version
This will display the version of CUDA installed.
-
Check that TensorFlow detects the GPU:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
Use the provided PowerShell script to bundle the server into an executable using PyInstaller:
pnpm run build-src-pythonThis will generate the server executable along with the required Python runtime.
Navigate to the frontend directory and install the required packages:
cd frontend
pnpm installStart the backend server and build the API client for the frontend:
pnpm run launch-server
pnpm run build-server-client-
Start the Tauri application in development mode:
pnpm run tauri dev
-
The backend server will automatically start and stop with the Tauri application.
-
Interact with the TensorFlow model via the Svelte-based UI.
To package the application for distribution, i have created a github actions that will build the application for windows. This is compatible with Tauri updater and public realease in private repository. Feel free to open an issue if you want to know more about it.
- Ensure all required dependencies are installed correctly for both the backend and frontend.
- I'll be more than happy if someone can help me to make this project work on WSL, Linux, MacOS.
- On windows, WSL we'll be a great addition to use more modern tensorflow versions.
- Contributions are welcome! Feel free to open issues and submit pull requests.
This project is licensed under the MIT License.