| 608 | } |
| 609 | |
| 610 | bool PackageManager::install_torch_async_raw(const std::string& cuda_version, |
| 611 | const std::string& torch_version, |
| 612 | UvRunner::RawOutputCallback on_output, |
| 613 | UvRunner::CompletionCallback on_complete) { |
| 614 | if (!ensure_venv()) |
| 615 | return false; |
| 616 | |
| 617 | if (!m_runner) { |
| 618 | m_runner = std::make_unique<UvRunner>(); |
| 619 | } |
| 620 | |
| 621 | if (m_runner->is_running()) { |
| 622 | LOG_ERROR("Another UV operation is already running"); |
| 623 | return false; |
| 624 | } |
| 625 | |
| 626 | const std::string cuda_tag = core::get_pytorch_cuda_tag(cuda_version); |
| 627 | LOG_INFO("PyTorch CUDA tag (async raw): {}", cuda_tag); |
| 628 | |
| 629 | std::string package = "torch"; |
| 630 | if (!torch_version.empty()) |
| 631 | package += "==" + torch_version; |
| 632 | |
| 633 | const std::string index_url = std::string(PYTORCH_INDEX) + cuda_tag; |
| 634 | |
| 635 | LOG_INFO("Installing {} from {} (async raw)", package, cuda_tag); |
| 636 | |
| 637 | m_runner->set_raw_output_callback(std::move(on_output)); |
| 638 | m_runner->set_completion_callback(std::move(on_complete)); |
| 639 | |
| 640 | std::vector<std::string> args = {"pip", "install", package, "--extra-index-url", index_url, |
| 641 | "--python", lfs::core::path_to_utf8(venv_python())}; |
| 642 | if (torch_version.empty()) |
| 643 | args.push_back("--upgrade"); |
| 644 | |
| 645 | return m_runner->start(args); |
| 646 | } |
| 647 | |
| 648 | bool PackageManager::poll() { |
| 649 | if (!m_runner) { |
no test coverage detected