Skip to content

Commit

Permalink
import numpy before setting dlopen flags (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
albanD authored and soumith committed Mar 5, 2017
1 parent 60736bd commit ac9245a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions torch/__init__.py
Expand Up @@ -31,6 +31,13 @@
# automatically filled by the dynamic loader.
import os as _dl_flags

# if we have numpy, it *must* be imported before the call to setdlopenflags()
# or there is risk that later c modules will segfault when importing numpy
try:
import numpy as np
except:
pass

# first check if the os package has the required flags
if not hasattr(_dl_flags, 'RTLD_GLOBAL') or not hasattr(_dl_flags, 'RTLD_NOW'):
try:
Expand Down

0 comments on commit ac9245a

Please sign in to comment.