Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freshly installed anaconda3 python crashes on use of MKL due to python fetching wrong dll's on import #8561

Closed
sigurof opened this issue Feb 15, 2018 · 23 comments

Comments

@sigurof
Copy link

sigurof commented Feb 15, 2018

Actual Behavior

Anaconda3's installation of Python with MKL on Windows crashes bad and outputs the following error message:

mkl_aa_fw_init_workdivision the procedure entry point could not be located in the dynamic link library C:\Users[my name]\Anaconda3\Library\bin\mkl_intel_thread.dll

Expected Behavior

I would normally expect python not to crash bad and output such an error message.

Steps to Reproduce

  • Open Anaconda Prompt
  • Type "python --version" to verify this is indeed Python 3.6.3 :: Anaconda custom (64-bit)
  • Type python to start python:
  • Type in the following:
import numpy as np
A = np.arange(2*3).reshape(2,3).astype(np.float32)
B = np.arange(2*3*2731).reshape(2,3,2731).astype(np.int16)
np.dot(A, B)
  • If like mine, your python isn't loading dll's correctly, behold the beautiful crash that ensues.

What is causing the error

dll hell. Some previous application on my computer has installed several mkl files (dll's) in C:\Windows\System32, which for some reason causes python to load those instead of the proper ones.
This issue is very similar to numpy/numpy#6923, which seems to be caused by the same set of files. The folks over there traced the dll's back to Amplitube, which is certainly installed on my computer (not anymore it ain't).
I have confirmed that "disabling" the files
C:\Windows\System32\mkl_intel_thread.dll
C:\Windows\System32\mkl_def.dll
C:\Windows\System32\mkl_core.dll
by renaming them to disabled_mkl_blablabla, fixes the issue. It then seems like python discovers the correct dll files in Anaconda3. I am going to see if uninstalling Amplitube fixes the issue.
Even though the issue is similar to the one linked above, I think it deserves a new post, since it literally took me days to figure this problem out.
Hope this post helps someone out there!

Anaconda or Miniconda version:

Anaconda version 1.6.5

Operating System:

Windows 10

conda info
     active environment : base
    active env location : C:\Users\[my name]\Anaconda3
            shell level : 1
       user config file : C:\SPB_Data\.condarc
 populated config files : C:\SPB_Data\.condarc
          conda version : 4.4.10
    conda-build version : 3.0.27
         python version : 3.6.3.final.0
       base environment : C:\Users\[my name]\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/r/win-64
                          https://conda.anaconda.org/r/noarch
                          https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
          package cache : C:\Users\[my name]\Anaconda3\pkgs
                          C:\Users\[my name]\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\[my name]\Anaconda3\envs
                          C:\Users\[my name]\AppData\Local\conda\conda\envs
                          C:\SPB_Data\.conda\envs
               platform : win-64
             user-agent : conda/4.4.10 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False
conda list --show-channel-urls
As I am in the base env, this list is very long. Also, probably not very relevant.

EDIT: 23-Feb 2019: Uninstalling Amplitube did resolve the problem.

@chenchen2015
Copy link

It appears that software like Amplitube will install another copy of MKL library DLLs to the system32 folder and therefore picked up by numpy and other libraries, in my case matplotlib, due to higher priority.

A simple solution for me now is to temporarily remove (or simply rename) the MKL dlls under system32 folder. I found that this way Amplitube can co-exist with Anaconda (or other Python environments that includes MKL) as I still want to use Amplitube.

@mingwandroid
Copy link

mingwandroid commented Apr 8, 2018

Then you need to ask Amplitube people to stop installing non-system DLLs into the System32 folder.

This is the worst thing a software developer can do with regards to DLL-hell. It is basically saying "we don't care about any other software on your computer so long as our software works OK"

@utkuaslan85
Copy link

I was also facing MKL error when running LogisticRegression from sklearn.linear_model in Spyder (Anaconda 3.6). And also I have Amplitube4 installed. I renamed file name of MKL library DLLs under system32 folder. Problem solved. Additionally Amplitube4 is working fine.

@scyap
Copy link

scyap commented Jul 22, 2018

Just started to learn programming and find this solution written in way easy to understand.

It works for me by renaming:
C:\Windows\System32\mkl_intel_thread.dll
C:\Windows\System32\mkl_def.dll
C:\Windows\System32\mkl_core.dll

Thanks!

@NavinSinghsays
Copy link

I don't have amplitube installed still I am facing the similar issue
import numpy as np A = np.arange(2*3).reshape(2,3).astype(np.float32) B = np.arange(2*3*2731).reshape(2,3,2731).astype(np.int16) np.dot(A, B)
when i run the above code i do get output though.
following are conda specs
`
(base) C:\Users\Navin>conda info

 active environment : base
active env location : C:\Users\Navin\Anaconda3
        shell level : 1
   user config file : C:\Users\Navin\.condarc

populated config files : C:\Users\Navin.condarc
conda version : 4.5.8
conda-build version : 3.10.5
python version : 3.6.5.final.0
base environment : C:\Users\Navin\Anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/pro/win-64
https://repo.anaconda.com/pkgs/pro/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\Navin\Anaconda3\pkgs
C:\Users\Navin\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\Navin\Anaconda3\envs
C:\Users\Navin\AppData\Local\conda\conda\envs
C:\Users\Navin.conda\envs
platform : win-64
user-agent : conda/4.5.8 requests/2.18.4 CPython/3.6.5 Windows/7 Wi
ndows/6.1.7600
administrator : False
netrc file : None
offline mode : False`
after running conda list --show-channel-urls

`
(base) C:\Users\Navin>conda info

 active environment : base
active env location : C:\Users\Navin\Anaconda3
        shell level : 1
   user config file : C:\Users\Navin\.condarc

populated config files : C:\Users\Navin.condarc
conda version : 4.5.8
conda-build version : 3.10.5
python version : 3.6.5.final.0
base environment : C:\Users\Navin\Anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/pro/win-64
https://repo.anaconda.com/pkgs/pro/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\Navin\Anaconda3\pkgs
C:\Users\Navin\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\Navin\Anaconda3\envs
C:\Users\Navin\AppData\Local\conda\conda\envs
C:\Users\Navin.conda\envs
platform : win-64
user-agent : conda/4.5.8 requests/2.18.4 CPython/3.6.5 Windows/7 Wi
ndows/6.1.7600
administrator : False
netrc file : None
offline mode : False`
error

@mingwandroid
Copy link

@NavinSinghsays, please type where mkl_core.dll from cmd.exe. While you may not have amplitube installed, something else may have put these DLLs somewhere they shouldn't be.

@NavinSinghsays
Copy link

when I executed the where mkl_core.dll on cmd.exe following is the o/p
C:\Users\Navin>where mkl_core.dll INFO: Could not find files for the given pattern(s).

when same code was executed on Anaconda prompt following is the o/p
(base) C:\Users\Navin>where mkl_core.dll C:\Users\Navin\Anaconda3\Library\bin\mkl_core.dll

@mingwandroid
Copy link

@NavinSinghsays does your code work outside of Spyder?

@NavinSinghsays
Copy link

yes, I tried the code on jupyterlab and the problem is same.

@mingwandroid
Copy link

Can you try it in the Python interpreter please?

@NavinSinghsays
Copy link

@mingwandroid Hey, I updated my OS and issue is resolved. Thank you for the help.

@heihaa
Copy link

heihaa commented Sep 24, 2018

Thank you for this thread!! It saved me! I uninstalled Amplitube and everything worked fine. I am relifed! No never more amplitube for me

@HasArslan
Copy link

Actual Behavior

Anaconda3's installation of Python with MKL on Windows crashes bad and outputs the following error message:

mkl_aa_fw_init_workdivision the procedure entry point could not be located in the dynamic link library C:\Users[my name]\Anaconda3\Library\bin\mkl_intel_thread.dll

i have the same problem. did you find a solution?

@sigurof
Copy link
Author

sigurof commented Jan 22, 2019

@HasArslan

Because pure python is extremely slow, numpy uses certain files with pre-compiled code (written in a faster language, like c++ or c), which it calls upon when you do heavy numerical operations. When you run a python script, it needs to search for these files in folders on your computer. Python has a list of places it will search (pythonpath, search it up), and when it finds the file it's looking for, it will use that.

The error message I posted, says that python couldn't find a certain function in the MKL library. This was due to python finding an older version of the mkl-files it was looking for, where this function didn't exist, in a folder with a higher search priority than the folder where numpy actually had put these files. The files python found, belonged to another application (Amplitube), which had sloppily put its dependencies (the files) in the System32 folder.

The solution for me was simply renaming the files that Amplitube uses (this could break amplitube though). Do NOT delete them, though, unless you are certain. Because then python wouldn't recognize the erroneous files anymore, and search all the way through the different directories until finding the file it was actually looking for.

If you have the same problem as me, you should check if a file with the same name as that which the error is referring to by chance is located in your System32 folder or any other folder in the pythonpath.
(The python path is basically a python variable with a list of paths). Note that the correct dll should also be somewhere on the pythonpath, so you have to know which one python is actually supposed to find.

@HasArslan
Copy link

HasArslan commented Jan 27, 2019 via email

@tirthshah147
Copy link

['System32\libiomp5md.dll', 'System32\mkl_core.dll', 'System32\mkl_def.dll','System32\mkl_intel_thread.dll', 'SysWOW64\libiomp5md.dll','SysWOW64\mkl_core.dll','SysWOW64\mkl_intel_thread.dll', 'SysWOW64\mkl_p4.dll', 'SysWOW64\mkl_p4m.dll','SysWOW64\mkl_p4m3.dll', 'SysWOW64\mkl_p4p.dll']

Remove all these ddl files from C:\Windows\SysWOW64 and C:\Windows\System32

Just do this and restart the application once again and hurrrahhhh!!! ur problem will be solved and it will open without showing any ordinal 242 error............just do it it is the only solution..

@mingwandroid
Copy link

We have another solution we're evaluating. If anyone can help we'd be grateful:

conda update -c rdonnelly python

@githubtd01
Copy link

After running conda udate --all I get the ordinal 242 error message too. It happens when I try to open Spyder as well as when I try to run code. I tryed to reinstall without success. Amplitude was never installed on my system. I also get the error "chcp" could not be found in Anaconda promt.

Running conda update -c rdonnelly python did solve the problem, but now Avast Antivirus thinks that pythonw is a virus (Avast sucks).

After the change, I get this problem: pyinstaller/pyinstaller#3740.

@lwbaqueros
Copy link

Another way which Works for me (I deleted all DLL files but the problem continued) was to downgrade ANACONDA to Anaconda3-5.2.0-Windows-x86_64.
I got the installer in this link

@msarahan
Copy link
Contributor

5.2.0 works because it's using an older MKL that's compatible with whatever else is on your system that's interfering.

The new python builds that Ray mentions are now on defaults. Before trying any other workarounds, please update python and try again.

@jazken
Copy link

jazken commented Mar 16, 2019

We have another solution we're evaluating. If anyone can help we'd be grateful:

conda update -c rdonnelly python

I just updated this, seems to work. What changed?

@mingwandroid
Copy link

mingwandroid commented Mar 18, 2019

We implemented a fix for dll hell but decided against enabling it by default as it's somewhat controversial.

Still dll hell is a fact on the ground and recommending people uninstall software isn't good enough. Please set the env var CONDA_DLL_SEARCH_MODIFICATION_ENABLE and be happy.

The python on my channel has this flag enabled by default. You are best off using the defaults channels packages though.

@ContinuumIO ContinuumIO locked as resolved and limited conversation to collaborators Mar 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests