2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
pythonAtLeast,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# buildInputs
|
2024-06-05 15:53:02 +00:00
|
|
|
llvmPackages,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# build-system
|
2024-06-05 15:53:02 +00:00
|
|
|
setuptools,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
numpy,
|
|
|
|
packaging,
|
|
|
|
psutil,
|
|
|
|
pyyaml,
|
|
|
|
safetensors,
|
|
|
|
torch,
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# tests
|
2024-06-05 15:53:02 +00:00
|
|
|
evaluate,
|
|
|
|
parameterized,
|
2024-09-19 14:19:46 +00:00
|
|
|
pytest7CheckHook,
|
2024-06-05 15:53:02 +00:00
|
|
|
transformers,
|
2024-09-19 14:19:46 +00:00
|
|
|
config,
|
|
|
|
cudatoolkit,
|
2023-04-29 16:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "accelerate";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "0.34.2";
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "huggingface";
|
2024-05-15 15:35:15 +00:00
|
|
|
repo = "accelerate";
|
2023-04-29 16:46:19 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-4kDNLta6gGev16A4hNOArTpoD8p6LMRwqwHS/DZjtz0=";
|
2023-04-29 16:46:19 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs = [ llvmPackages.openmp ];
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
build-system = [ setuptools ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
dependencies = [
|
2023-04-29 16:46:19 +00:00
|
|
|
numpy
|
|
|
|
packaging
|
|
|
|
psutil
|
|
|
|
pyyaml
|
2024-01-02 11:29:13 +00:00
|
|
|
safetensors
|
2023-04-29 16:46:19 +00:00
|
|
|
torch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
evaluate
|
|
|
|
parameterized
|
2024-04-21 15:54:59 +00:00
|
|
|
pytest7CheckHook
|
2023-04-29 16:46:19 +00:00
|
|
|
transformers
|
|
|
|
];
|
2024-06-05 15:53:02 +00:00
|
|
|
preCheck =
|
|
|
|
''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
export PATH=$out/bin:$PATH
|
|
|
|
''
|
|
|
|
+ lib.optionalString config.cudaSupport ''
|
|
|
|
export TRITON_PTXAS_PATH="${cudatoolkit}/bin/ptxas"
|
|
|
|
'';
|
2023-04-29 16:46:19 +00:00
|
|
|
pytestFlagsArray = [ "tests" ];
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# try to download data:
|
|
|
|
"FeatureExamplesTests"
|
|
|
|
"test_infer_auto_device_map_on_t0pp"
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
# require socket communication
|
|
|
|
"test_explicit_dtypes"
|
|
|
|
"test_gated"
|
|
|
|
"test_invalid_model_name"
|
|
|
|
"test_invalid_model_name_transformers"
|
|
|
|
"test_no_metadata"
|
|
|
|
"test_no_split_modules"
|
|
|
|
"test_remote_code"
|
|
|
|
"test_transformers_model"
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
# nondeterministic, tests GC behaviour by thresholding global ram usage
|
|
|
|
"test_free_memory_dereferences_prepared_components"
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
# set the environment variable, CC, which conflicts with standard environment
|
|
|
|
"test_patch_environment_key_exists"
|
|
|
|
]
|
|
|
|
++ lib.optionals (pythonAtLeast "3.12") [
|
|
|
|
# RuntimeError: Dynamo is not supported on Python 3.12+
|
|
|
|
"test_convert_to_fp32"
|
|
|
|
"test_dynamo_extract_model"
|
|
|
|
"test_send_to_device_compiles"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
|
2024-06-05 15:53:02 +00:00
|
|
|
# usual aarch64-linux RuntimeError: DataLoader worker (pid(s) <...>) exited unexpectedly
|
|
|
|
"CheckpointTest"
|
|
|
|
# TypeError: unsupported operand type(s) for /: 'NoneType' and 'int' (it seems cpuinfo doesn't work here)
|
|
|
|
"test_mpi_multicpu_config_cmd"
|
|
|
|
]
|
|
|
|
++ lib.optionals (!config.cudaSupport) [
|
|
|
|
# requires ptxas from cudatoolkit, which is unfree
|
|
|
|
"test_dynamo_extract_model"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals (stdenv.hostPlatform.isDarwin) [
|
2024-09-19 14:19:46 +00:00
|
|
|
# RuntimeError: 'accelerate-launch /nix/store/a7vhm7b74a7bmxc35j26s9iy1zfaqjs...
|
|
|
|
"test_accelerate_test"
|
|
|
|
"test_init_trackers"
|
|
|
|
"test_init_trackers"
|
|
|
|
"test_log"
|
|
|
|
"test_log_with_tensor"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
|
2024-06-05 15:53:02 +00:00
|
|
|
# RuntimeError: torch_shm_manager: execl failed: Permission denied
|
|
|
|
"CheckpointTest"
|
|
|
|
];
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
disabledTestPaths = lib.optionals (!(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64)) [
|
2023-08-04 22:07:22 +00:00
|
|
|
# numerous instances of torch.multiprocessing.spawn.ProcessRaisedException:
|
|
|
|
"tests/test_cpu.py"
|
|
|
|
"tests/test_grad_sync.py"
|
|
|
|
"tests/test_metrics.py"
|
|
|
|
"tests/test_scheduler.py"
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "accelerate" ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
meta = {
|
2023-04-29 16:46:19 +00:00
|
|
|
homepage = "https://huggingface.co/docs/accelerate";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Simple way to train and use PyTorch models with multi-GPU, TPU, mixed-precision";
|
2023-04-29 16:46:19 +00:00
|
|
|
changelog = "https://github.com/huggingface/accelerate/releases/tag/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ bcdarwin ];
|
2023-04-29 16:46:19 +00:00
|
|
|
mainProgram = "accelerate";
|
|
|
|
};
|
|
|
|
}
|