提交 fb3ceef9 authored 作者: lamblin's avatar lamblin

Merge pull request #1425 from nouiz/mac_anaconda

buildbot python 3.3.0 and Mac anaconda instruction.
...@@ -527,7 +527,7 @@ MacOS ...@@ -527,7 +527,7 @@ MacOS
----- -----
There are various ways to install Theano dependencies on a Mac. There are various ways to install Theano dependencies on a Mac.
Here we describe the process in detail with EPD or with MacPorts, but if you did Here we describe the process in detail with EPD, Anaconda or with MacPorts, but if you did
it differently and it worked, please let us know the details on the it differently and it worked, please let us know the details on the
`theano-users`_ mailing-list, so that we can add alternate instructions `theano-users`_ mailing-list, so that we can add alternate instructions
here. here.
...@@ -581,6 +581,54 @@ Then you must install g++. You can do this by installing XCode. See the first bu ...@@ -581,6 +581,54 @@ Then you must install g++. You can do this by installing XCode. See the first bu
if the user did the modification and if not, we tell him how to do if the user did the modification and if not, we tell him how to do
it. it.
Anaconda 1.5
~~~~~~~~~~~~
An easy way to install most of the dependencies is to install
`Anaconda <http://continuum.io/downloads.html>`_. There is a free
version available to everybody. If you install their ``MKL
Optimizations`` product (free for academic, ~30$ otherwise) Theano
will also be optimized as we will reuse the faster BLAS version
automatically.
Anaconda installation includes in particular Python (and the development headers),
numpy, scipy, nose, sphinx, pip, and a acceptable BLAS version. The Mac OS and
Linux version do not include g++.
After installing Anaconda, in a terminal execute this command to
install the latest Theano release:
.. code-block:: bash
$ pip install Theano
To install the missing Theano optional dependency (pydot):
.. code-block:: bash
$ conda install pydot
If you want the bleeding edge version, `download
and install git <http://git-scm.com/downloads>`_. Then in a
terminal excute this command:
.. code-block:: bash
$ sudo pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
See the section `install_bleeding_edge`_ for more
information on the bleading edge version.
Then you must install g++. You can do this by installing XCode. See the first bullet in the :ref:`macports` section.
.. note::
If you use the trunk or a version after 0.6rc3 of Theano, we try to
automaticaly link with the python library. Due to Mac OS
peculiarities, we need a user intervention to do it. We detect
if the user did the modification and if not, we tell him how to do
it.
.. _macports: .. _macports:
MacPorts MacPorts
......
...@@ -479,7 +479,7 @@ class KeyData(object): ...@@ -479,7 +479,7 @@ class KeyData(object):
protocol=cPickle.HIGHEST_PROTOCOL) protocol=cPickle.HIGHEST_PROTOCOL)
except cPickle.PicklingError: except cPickle.PicklingError:
_logger.warning("Cache leak due to unpickle-able key data %s", _logger.warning("Cache leak due to unpickle-able key data %s",
self.keys) self.keys)
os.remove(self.key_pkl) os.remove(self.key_pkl)
raise raise
...@@ -664,8 +664,8 @@ class ModuleCache(object): ...@@ -664,8 +664,8 @@ class ModuleCache(object):
# os. So it is normal that this happens from time # os. So it is normal that this happens from time
# to time. # to time.
_logger.warning("ModuleCache.refresh() Found key " _logger.warning("ModuleCache.refresh() Found key "
"without dll in cache, deleting it. %s", "without dll in cache, deleting it. %s",
key_pkl) key_pkl)
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg="missing module file", level=logging.INFO) msg="missing module file", level=logging.INFO)
continue continue
...@@ -674,7 +674,7 @@ class ModuleCache(object): ...@@ -674,7 +674,7 @@ class ModuleCache(object):
def unpickle_failure(): def unpickle_failure():
_logger.info("ModuleCache.refresh() Failed to " _logger.info("ModuleCache.refresh() Failed to "
"unpickle cache file %s", key_pkl) "unpickle cache file %s", key_pkl)
try: try:
key_data = cPickle.load(open(key_pkl, 'rb')) key_data = cPickle.load(open(key_pkl, 'rb'))
...@@ -779,9 +779,9 @@ class ModuleCache(object): ...@@ -779,9 +779,9 @@ class ModuleCache(object):
level=logging.DEBUG) level=logging.DEBUG)
else: else:
_logger.debug('Found duplicated module not ' _logger.debug('Found duplicated module not '
'old enough yet to be deleted ' 'old enough yet to be deleted '
'(age: %s): %s', '(age: %s): %s',
age, entry) age, entry)
continue continue
# Remember the map from a module's hash to the KeyData # Remember the map from a module's hash to the KeyData
...@@ -870,7 +870,7 @@ class ModuleCache(object): ...@@ -870,7 +870,7 @@ class ModuleCache(object):
compilelock.release_lock() compilelock.release_lock()
_logger.debug('Time needed to refresh cache: %s', _logger.debug('Time needed to refresh cache: %s',
(time.time() - start_time)) (time.time() - start_time))
return too_old_to_use return too_old_to_use
...@@ -934,8 +934,8 @@ class ModuleCache(object): ...@@ -934,8 +934,8 @@ class ModuleCache(object):
_logger.error(e) _logger.error(e)
if e.errno == 31: if e.errno == 31:
_logger.error('There are %i files in %s', _logger.error('There are %i files in %s',
len(os.listdir(config.compiledir)), len(os.listdir(config.compiledir)),
config.compiledir) config.compiledir)
raise raise
try: try:
compile_steps = fn(location=location).__iter__() compile_steps = fn(location=location).__iter__()
...@@ -958,7 +958,7 @@ class ModuleCache(object): ...@@ -958,7 +958,7 @@ class ModuleCache(object):
if module_hash in self.module_hash_to_key_data: if module_hash in self.module_hash_to_key_data:
_logger.debug("Duplicated module! Will re-use the " _logger.debug("Duplicated module! Will re-use the "
"previous one") "previous one")
duplicated_module = True duplicated_module = True
# Load the already existing module. # Load the already existing module.
key_data = self.module_hash_to_key_data[module_hash] key_data = self.module_hash_to_key_data[module_hash]
...@@ -966,7 +966,7 @@ class ModuleCache(object): ...@@ -966,7 +966,7 @@ class ModuleCache(object):
# should not be used considering that the module should # should not be used considering that the module should
# already be compiled. # already be compiled.
module = self.module_from_key(key=None, module = self.module_from_key(key=None,
key_data=key_data) key_data=key_data)
name = module.__file__ name = module.__file__
# Add current key to the set of keys associated to the # Add current key to the set of keys associated to the
# same module. We only save the KeyData object of # same module. We only save the KeyData object of
...@@ -1007,7 +1007,7 @@ class ModuleCache(object): ...@@ -1007,7 +1007,7 @@ class ModuleCache(object):
name = module.__file__ name = module.__file__
_logger.debug("Adding module to cache %s %s", _logger.debug("Adding module to cache %s %s",
key, name) key, name)
assert name.startswith(location) assert name.startswith(location)
assert name not in self.module_from_name assert name not in self.module_from_name
# Changing the hash of the key is not allowed during # Changing the hash of the key is not allowed during
...@@ -1251,7 +1251,7 @@ class ModuleCache(object): ...@@ -1251,7 +1251,7 @@ class ModuleCache(object):
compilelock.get_lock() compilelock.get_lock()
try: try:
for base_dir in ('cuda_ndarray', 'cutils_ext', 'lazylinker_ext', for base_dir in ('cuda_ndarray', 'cutils_ext', 'lazylinker_ext',
'scan_perform'): 'scan_perform'):
to_delete = os.path.join(self.dirname, base_dir + '.delete.me') to_delete = os.path.join(self.dirname, base_dir + '.delete.me')
if os.path.isdir(to_delete): if os.path.isdir(to_delete):
try: try:
...@@ -1266,7 +1266,7 @@ class ModuleCache(object): ...@@ -1266,7 +1266,7 @@ class ModuleCache(object):
shutil.move(to_rename, to_delete) shutil.move(to_rename, to_delete)
except Exception: except Exception:
_logger.warning('Could not move %s to %s', _logger.warning('Could not move %s to %s',
to_rename, to_delete) to_rename, to_delete)
finally: finally:
compilelock.release_lock() compilelock.release_lock()
...@@ -1370,7 +1370,7 @@ class ModuleCache(object): ...@@ -1370,7 +1370,7 @@ class ModuleCache(object):
finally: finally:
compilelock.release_lock() compilelock.release_lock()
_logger.debug('Time spent checking keys: %s', _logger.debug('Time spent checking keys: %s',
self.time_spent_in_check_key) self.time_spent_in_check_key)
def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG, def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
...@@ -1391,14 +1391,14 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG, ...@@ -1391,14 +1391,14 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
except Exception, e: except Exception, e:
# If parent still exists, mark it for deletion by a future refresh() # If parent still exists, mark it for deletion by a future refresh()
_logger.debug('In _rmtree, encountered exception: %s(%s)', _logger.debug('In _rmtree, encountered exception: %s(%s)',
type(e), e) type(e), e)
if os.path.exists(parent): if os.path.exists(parent):
try: try:
_logger.info('placing "delete.me" in %s', parent) _logger.info('placing "delete.me" in %s', parent)
open(os.path.join(parent, 'delete.me'), 'w').close() open(os.path.join(parent, 'delete.me'), 'w').close()
except Exception, ee: except Exception, ee:
_logger.warning("Failed to remove or mark cache directory %s " _logger.warning("Failed to remove or mark cache directory %s "
"for removal %s", parent, ee) "for removal %s", parent, ee)
_module_cache = None _module_cache = None
...@@ -1416,7 +1416,7 @@ def get_module_cache(dirname, init_args=None): ...@@ -1416,7 +1416,7 @@ def get_module_cache(dirname, init_args=None):
atexit.register(_module_cache._on_atexit) atexit.register(_module_cache._on_atexit)
elif init_args: elif init_args:
_logger.warning('Ignoring init arguments for module cache because it ' _logger.warning('Ignoring init arguments for module cache because it '
'was created prior to this call') 'was created prior to this call')
if _module_cache.dirname != dirname: if _module_cache.dirname != dirname:
_logger.warning("Returning module cache instance with different " _logger.warning("Returning module cache instance with different "
"dirname (%s) than you requested (%s)", "dirname (%s) than you requested (%s)",
...@@ -1682,6 +1682,26 @@ class GCC_compiler(object): ...@@ -1682,6 +1682,26 @@ class GCC_compiler(object):
if (python_inc.count('Python.framework') > 0 and if (python_inc.count('Python.framework') > 0 and
config.cmodule.mac_framework_link): config.cmodule.mac_framework_link):
cxxflags.extend(['-framework', 'Python']) cxxflags.extend(['-framework', 'Python'])
if 'Anaconda' in sys.version:
new_path = os.path.join(sys.prefix, "lib")
v = os.getenv("DYLD_FALLBACK_LIBRARY_PATH", None)
if v is not None:
# This will resolve symbolic links
v = os.path.realpath(v)
# The python __import__ don't seam to take into account
# the new env variable "DYLD_FALLBACK_LIBRARY_PATH"
# when we set with os.environ['...'] = X or os.putenv()
# So we tell the user and tell him what todo.
if v is None or new_path not in v.split(":"):
raise Exception(
"The environment variable "
"'DYLD_FALLBACK_LIBRARY_PATH' does not contain "
"the '%s' path in its value. This will make "
"Theano unable to compile c code. Update "
"'DYLD_FALLBACK_LIBRARY_PATH' to contain the "
"said value, this will fix this error."
% new_path)
return cxxflags return cxxflags
...@@ -1815,8 +1835,8 @@ class GCC_compiler(object): ...@@ -1815,8 +1835,8 @@ class GCC_compiler(object):
# sometimes, the linker cannot find -lpython so we need to tell it # sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located # explicitly where it is located
# this returns somepath/lib/python2.x # this returns somepath/lib/python2.x
python_lib = distutils.sysconfig.get_python_lib(plat_specific=1, \ python_lib = distutils.sysconfig.get_python_lib(plat_specific=1,
standard_lib=1) standard_lib=1)
python_lib = os.path.dirname(python_lib) python_lib = os.path.dirname(python_lib)
if python_lib not in lib_dirs: if python_lib not in lib_dirs:
lib_dirs.append(python_lib) lib_dirs.append(python_lib)
...@@ -1833,7 +1853,7 @@ class GCC_compiler(object): ...@@ -1833,7 +1853,7 @@ class GCC_compiler(object):
cppfile.close() cppfile.close()
lib_filename = os.path.join(location, '%s.%s' % lib_filename = os.path.join(location, '%s.%s' %
(module_name, get_lib_extension())) (module_name, get_lib_extension()))
_logger.debug('Generating shared lib %s', lib_filename) _logger.debug('Generating shared lib %s', lib_filename)
cmd = ['g++', get_gcc_shared_library_arg(), '-g'] cmd = ['g++', get_gcc_shared_library_arg(), '-g']
......
...@@ -12,9 +12,11 @@ me='lisa@iro.umontreal.ca' ...@@ -12,9 +12,11 @@ me='lisa@iro.umontreal.ca'
#Those file contain the output of the do_nightly_build script. #Those file contain the output of the do_nightly_build script.
files=["/tmp/do_nightly_build_theano", "/tmp/do_nightly_build_pylearn", files=["/tmp/do_nightly_build_theano", "/tmp/do_nightly_build_pylearn",
"/tmp/do_nightly_build_deeplearning", "/tmp/do_nightly_build_pylearn2", "/tmp/do_nightly_build_deeplearning", "/tmp/do_nightly_build_pylearn2",
"/tmp/do_nightly_build_theano_python2.4"] "/tmp/do_nightly_build_theano_python2.4",
"/tmp/do_nightly_build_theano_python3.3.0",
]
msgs=['Theano buildbot', 'Pylearn buildbot', 'Deep Learning Tutorial buildbot', msgs=['Theano buildbot', 'Pylearn buildbot', 'Deep Learning Tutorial buildbot',
'Pylearn2 buildbot', 'Theano Python2.4 buildbot'] 'Pylearn2 buildbot', 'Theano Python2.4 buildbot', 'Theano Python3.3.0 buildbot']
print files print files
print msgs print msgs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论