From ab9c624167ac5c3539282f55afb18763e7370f96 Mon Sep 17 00:00:00 2001 From: OwnerSunshine530 Date: Sun, 14 Jun 2026 19:46:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bench.py=20=E5=9C=A8=20import=20torch=20?= =?UTF-8?q?=E5=89=8D=E8=A1=A5=E4=B8=8A=20baseline=20=E7=9A=84=20libraries?= =?UTF-8?q?=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- 代码/code/bench.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/代码/code/bench.py b/代码/code/bench.py index 272197c..e86967e 100644 --- a/代码/code/bench.py +++ b/代码/code/bench.py @@ -11,9 +11,18 @@ bench.run_once({"fp16": False, "expert_merge": False}) # FP32 参考跑 bench.run_once({"signid_mode": "modulo"}) # 取模 vs clamp """ +import os +import sys import time from pathlib import Path +# baseline 把依赖装在 --target 目录(非默认 site-packages),在 kernel 里 import +# 之前必须先把它加到 sys.path,否则 import torch 会 ModuleNotFoundError。 +for _p in ("/home/aistudio/external-libraries", "/home/aistudio/libraries", + os.path.abspath("../libraries"), os.path.abspath("./libraries")): + if os.path.isdir(_p) and _p not in sys.path: + sys.path.insert(0, _p) + import torch from torch.utils.data import DataLoader