PhotoFF Installation Guide
Prerequisites
Before installing PhotoFF, ensure you have the following prerequisites:
- Python 3.9 or newer
- NVIDIA GPU with CUDA support
- CUDA Toolkit 11.0 or newer - Required for compiling the CUDA components
- Visual Studio with C++ support (Windows) - Required for the CUDA compiler
- CFFI - Used for interfacing between Python and the CUDA library
- Pillow - Used for I/O operations and text rendering
- NumPy - Used only for memory management when transferring images from Pillow to CUDA
Python Dependencies
Install the required Python packages:
Note: - CFFI is essential for PhotoFF as it provides the bridge between Python and the CUDA-accelerated DLL - Pillow is used for loading and saving images, as well as text rendering functions - NumPy is only used for efficient memory management when transferring image data between Pillow and CUDA buffers
Installing CUDA Toolkit
- Download the CUDA Toolkit from the NVIDIA Developer website
- Follow the installation instructions for your operating system
- Make sure the CUDA binaries are in your system PATH (this usually happens automatically during installation)
- Verify your installation by running
nvcc --version
in your terminal
Install from Source
This method builds and installs the package from source code:
-
Clone the repository:
-
Compile the CUDA DLL:
-
Move the compiled
photoff.dll
to a directory in your system PATH or add the directory containing the DLL to your PATH environment variable. -
Install the Python package:
Verifying the Installation
To verify your installation, run the following Python code:
from photoff.operations.fill import fill_color
from photoff.io import save_image
from photoff.core.types import CudaImage, RGBA
# Create a 200x200 red square
img = CudaImage(200, 200)
fill_color(img, RGBA(255, 0, 0, 255))
save_image(img, "red_square.png")
img.free()
print("Installation successful!")
If you see a 200x200 red square image saved as "red_square.png" and the message "Installation successful!" printed to the console, your installation is working correctly.