Skip to content

Conversation

@oleksandr-pavlyk
Copy link
Contributor

Used pthread_atfork to restore environment variable MKL_THREADING_LAYER for the forked process.

@peterbell10 @rgommers

Closes #14

Using the environment as specified in #14, and

# file iss14.py
def do_test(*args):
    import os
    print("in do_test   ", os.getenv("MKL_THREADING_LAYER", None))
    import torch; import numpy as np
    x = np.random.rand(100)
    x.dot(x)

if __name__ == '__main__':
    import multiprocessing as mp
    import os
    print("in __main__ before mkl   ", os.getenv("MKL_THREADING_LAYER", None))
    import mkl
    print("in __main__ after mkl   ", os.getenv("MKL_THREADING_LAYER", None))

    mp = mp.get_context('spawn')
    with mp.Pool(2) as p:
        p.map(do_test, range(2))

With this fix I am getting:

(debug_pytorch) [22:44:14 ansatnuc04 wd]$ python iss14.py
in __main__ before mkl    None
in __main__ after mkl    None
in do_test    None
in do_test    None
(debug_pytorch) [22:44:18 ansatnuc04 wd]$ MKL_THREADING_LAYER=GNU python iss14.py
in __main__ before mkl    GNU
in __main__ after mkl    GNU
in do_test    GNU
in do_test    GNU

1. Use `pthread_atfork` to restore MKL threading layer environment variable
   set by init code for the forked process.

2. Fixed multiple GCC compiler warnings.
1. Remove use of six, and remove mention of its requirement in setup
2. No longer attempt to infer MKL location from numpy's distutils
   Always require MKLROOT variable to be set.
Added Cython directives for language_level=2
Copy link

@anton-malakhov anton-malakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@oleksandr-pavlyk oleksandr-pavlyk merged commit 6f64750 into master May 25, 2021
@oleksandr-pavlyk oleksandr-pavlyk deleted the fixed-issue-14 branch May 25, 2021 12:11
@rgommers
Copy link

Thanks @oleksandr-pavlyk!

@rgommers
Copy link

It would be good to know when this makes its way into conda defaults and conda-forge. For conda-forge I know where to look (https://github.com/conda-forge/mkl-service-feedstock). Not sure about defaults, except try conda search mkl-service sometime in the future. I assume this will be in the mkl-service 2.4.0 release?

@oleksandr-pavlyk
Copy link
Contributor Author

oleksandr-pavlyk commented May 25, 2021

Yes, I was thinking of releasing 2.4.0 today. I am looking through new functionality in MKL to add to service.

mkl_set_num_stripes, mkl_get_num_stripes

Also adding support for more code in mkl_enable_instructions function.

@oleksandr-pavlyk
Copy link
Contributor Author

@rgommers Fixed build break in conda-forge/mkl-service-feedstock#17

@rgommers
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mkl-service should not set MKL_THREADING_LAYER environment variable

3 participants