A small collection of Python shortcut scripts for common tasks.
Project description
pycuts
pycuts is a small Python library that provides a collection of shortcut functions for common operations across various libraries, particularly for PyTorch and Hugging Face Hub environments.
Installation
You can install pycuts directly from PyPI:
pip install pycuts
Shortcuts
Function | Return Type | Description |
---|---|---|
device() |
torch.device |
Determines the best device to use (cuda , mps , or cpu ). |
gpu() |
bool |
Returns True if a GPU ("cuda" or "mps") is available, otherwise False . |
torch_dtype() |
torch.dtype |
Determines the appropriate tensor precision based on the device. |
synchronize() |
None |
Waits for all kernels in all streams on the given device to complete. |
empty_cache() |
None |
Clears the GPU memory to prevent out-of-memory errors. |
device_count() |
int |
Returns the number of available devices (e.g., number of GPUs). |
manual_seed(seed) |
None |
Sets the random seed for reproducible behavior across CPU/GPU. |
is_spaces() |
bool |
Returns True if running in a Hugging Face Space, otherwise False . |
is_zero_gpu_space() |
bool |
Returns True if running in a zero-GPU Hugging Face Space. |
Examples
import pycuts
print(f"current device is: {pycuts.device()}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycuts-1.0.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file pycuts-1.0.0.tar.gz
.
File metadata
- Download URL: pycuts-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d116ad085cbadb2f52cc16401d7e39642f3cfff31257e121f0447f71c7808f0c |
|
MD5 | 80003878e5ed47df5e696e360d2cd91a |
|
BLAKE2b-256 | 33ca7aa12141395e9454e1df1e04c36e23db6857bb93c9f0c9a43a4a2684036c |
File details
Details for the file pycuts-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pycuts-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f50f94203cc0907a80957f17a43e177fbb5fd81618fda5880da2c0c59d928135 |
|
MD5 | dd08151caec0fc51addcb88f8129d370 |
|
BLAKE2b-256 | f1889e4a0eb22fb92eb161993a8d8288e38da4df7819943d19b8708797d11e16 |