conansherry / detectron2

detectron2 windows build
Apache License 2.0
223 stars 54 forks source link

ImportError: DLL load failed while importing win32file #8

Closed csnam closed 4 years ago

csnam commented 4 years ago

i had proceed according to the install instruction When I ran the demonstration, I got the following error.

importError: DLL load failed while importing win32file

I'd appreciate it if someone would help me

command list

conda install pytorch torchvision -c pytorch conda install opencv pip install git+https://github.com/facebookresearch/fvcore pip install cython; pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

two file modify argument_spec.h , cast.h

"C:\Program Files (x86)\Microsoft Visual Studio\2019\community\VC\Auxiliary\Build\vcvars64.bat" cd detectron2 python setup.py build develop

there was no error until the command above

execute demo

python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input input1.jpg --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl`

... ... File "C:\Users\CSNAM\Anaconda3\envs\detectron_env\lib\site-packages\portalocker__init__.py", line 4, in from . import portalocker File "C:\Users\CSNAM\Anaconda3\envs\detectron_env\lib\site-packages\portalocker\portalocker.py", line 9, in import win32file ImportError: DLL load failed while importing win32file

Did i miss something ?

jefflomax commented 4 years ago

I also had to set num_devices to 1 in evaluator.py (there may be a more elegant way to disable torch.distributed). My environment is a little different as I'm building against CUDA 10.0 instead of 10.1. pip list on my environment shows portalocker 1.5.2

And your test ran fine for me:

python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input "C:\programs\pytorch\detectron2\datasets\coco\val2017\000000000139.jpg" --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
[02/10 16:16:28 detectron2]: Arguments: Namespace(confidence_threshold=0.5, config_file='configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml', input=['C:\\programs\\pytorch\\detectron2\\datasets\\coco\\val2017\\000000000139.jpg'], opts=['MODEL.WEIGHTS', 'detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl'], output=None, video_input=None, webcam=False)
WARNING [02/10 16:16:28 d2.config.compat]: Config 'configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml' has no VERSION. Assuming it to be compatible with latest v2.
model_final_f10217.pkl: 178MB [00:07, 25.4MB/s]
[02/10 16:16:42 detectron2]: C:\programs\pytorch\detectron2\datasets\coco\val2017\000000000139.jpg: detected 21 instances in 2.83s
jefflomax commented 4 years ago

What version of Python? https://github.com/mhammond/pywin32/issues/1431

csnam commented 4 years ago

With your advice, the error was eliminated and it was successfully implemented. Thank you. i had needed the below command "conda install pywin32"

nickums commented 3 years ago

my 'conda install pywin32' gives me CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json ..... SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))

fingoldo commented 2 years ago

What helped me was issuing the following commands in the x64 command line:

cd C:\ProgramData\Anaconda3\Scripts python pywin32_postinstall.py -install