nni
nni copied to clipboard
导入自定义文件时出现ModuleNotFoundError: No module named 'dataset_process'的问题
Describe the issue:
在使用torch的dataset自定义数据集时,由于直接在同文件内自定义类时会报错,选择单独生成一个python文件,内部完成数据集的定义,并引入该文件完成,但是在引入自定义文件dataset_process时,程序报错
Environment:
- NNI version: v2.8
- Training service (local|remote|pai|aml|etc):local|
- Client OS:windows11
- Server OS (for remote mode only):
- Python version:3.6
- PyTorch/TensorFlow version:1.7.1
- Is conda/virtualenv/venv used?:conda is used
- Is running in Docker?:no
Configuration:
- Experiment config (remember to remove secrets!):

- Search space:
Log message:
- nnimanager.log: nnimanager.log
- dispatcher.log: dispatcher.log
- nnictl stdout and stderr:
How to reproduce it?:
使用retiarii在pytorch框架下,引入包含自定义数据集类的代码,如下:
并在nni主程序中import该文件即可报错
What is your trial code directory? Where did you run the experiment? Did you use any tricks like sys.path.insert
to manipulate Python PATH?
Trial code directory was in my desktop and I simply opened and run it in pycharm. I didn’t use the tricks you mentioned. I would give it a try. Thanks for the advice!
Did you use any tricks like sys.path.insert to manipulate Python PATH?
I mean, please don't use them.
Could you try to run your program in command line like python xxx.py
? I'm not sure what pytorch is doing to your code. What is the working directory and etc.
I try to rerun it but get the same problem. This is the working directory and pytorch is 1.7.1 version. Could it be a little old?
I don't think it's related to pytorch version.
Can you import dataset_process
in your current working directory?