nni icon indicating copy to clipboard operation
nni copied to clipboard

导入自定义文件时出现ModuleNotFoundError: No module named 'dataset_process'的问题

Open Fusheng-code opened this issue 2 years ago • 5 comments

Describe the issue: 在使用torch的dataset自定义数据集时,由于直接在同文件内自定义类时会报错,选择单独生成一个python文件,内部完成数据集的定义,并引入该文件完成,但是在引入自定义文件dataset_process时,程序报错 image

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!):
image
  • Search space: image

Log message:

How to reproduce it?: 使用retiarii在pytorch框架下,引入包含自定义数据集类的代码,如下: image 并在nni主程序中import该文件即可报错

Fusheng-code avatar Jul 04 '22 13:07 Fusheng-code

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?

matluster avatar Jul 11 '22 02:07 matluster

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!

Fusheng-code avatar Jul 11 '22 03:07 Fusheng-code

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.

ultmaster avatar Jul 11 '22 08:07 ultmaster

image 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?

Fusheng-code avatar Jul 14 '22 07:07 Fusheng-code

I don't think it's related to pytorch version.

Can you import dataset_process in your current working directory?

ultmaster avatar Jul 15 '22 08:07 ultmaster