Open hmckay opened 2 years ago
Hi @hmckay,
adapt is tested on macos by github at every commit whithout issue, but I think it install tensorflow instead of tensorflow-macos. Does tensorflow-macos work the same as tensorflow?
Have you tried pip install git+https://github.com/adapt-python/adapt.git
? Or to manually install adapt by cloning the repository, removing the requirement and run pip install .
in the adapt repo?
I think you can install tensorflow on a mac, but miss out on a lot of performance gains (I'm not even sure tensorflow hooks into the GPU on the m1s properly). I'm not an expert on using tensorflow, but from what I can tell tensorflow and tensorflow-macos have the same functionality, but tensorflow-macos has been optimised for macs. Once it's been installed you import everything the same way as you would from tensorflow (so as far as I can tell it's just a pip issue)
When I manually try to install using pip install . I get the following error: ERROR: Could not find a version that satisfies the requirement tensorflow>=2.0 (from adapt) (from versions: none) ERROR: No matching distribution found for tensorflow>=2.0
I modified the install_requires in setup.py to the following:
install_requires=["numpy>=1.16", "scipy>=1.0", "scikit-learn>=0.2", "cvxopt>=1.2", "tensorflow>=2.0; platform_system !='Darwin' and platform_machine!='arm64'", "tensorflow-macos>=2.0; platform_system =='Darwin' and platform_machine=='arm64'", "tensorflow-metal; platform_system =='Darwin' and platform_machine=='arm64'"],
I was then able to install with pip install .
Edit: I think tensorflow-macos has also been optimised for the intel macs too, so the requirement of platform_machine=='arm64' may not be necessary
Hi @hmckay, Yes it seems to be a good idea to allow tensorflow-macos instead of tensorflow for mac users. However I wonder if we can make a condition like:
if OS == "macos", then requirements = ["tensorflow>=2.0 OR tensorflow-macos>=2.0"] if OS != "macos", then requirements = ["tensorflow>=2.0"]
Do you think, we can do something like that in setup.py ?
This seems to work for me (haven't tested it on anything other than a mac with tensorflow-macos installed though):
from setuptools import setup, find_packages
from pathlib import Path
import platform
import pkg_resources
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
INSTALL_REQUIRES = ["numpy>=1.16", "scipy>=1.0", "scikit-learn>=0.2", "cvxopt>=1.2"]
def get_install_requires():
if platform.system() != 'Darwin':
INSTALL_REQUIRES.append("tensorflow>=2.0")
else:
installed_pkgs = [pkg_name.project_name for pkg_name in pkg_resources.working_set]
if "tensorflow-macos" in ','.join(installed_pkgs):
INSTALL_REQUIRES.extend(["tensorflow-macos>=2.0","tensorflow-metal"])
else:
INSTALL_REQUIRES.append("tensorflow>=2.0")
return INSTALL_REQUIRES
setup(
name='adapt',
version='0.4.1',
description='Awesome Domain Adaptation Python Toolbox for Tensorflow and Scikit-learn',
url='https://github.com/adapt-python/adapt.git',
author='Antoine de Mathelin',
author_email='antoine.demat@gmail.com',
license='BSD-2',
packages=find_packages(exclude=["tests"]),
install_requires=get_install_requires(),
zip_safe=False,
long_description=long_description,
long_description_content_type='text/markdown'
)
Hi @hmckay, It seems nice! Can you please open a pull-request with your modification of the setup.py? It will launch the tests on other OS, we will see if it works. Best,
Currently using a mac M1, I have tensorflow-deps, tensorflow-macos(2.9.0) and tensorflow-metal installed (all working fine), but when I try to "pip install adapt" I have the following conflict: adapt 0.4.1 depends on tensorflow>=2.0
Checking my current tensorflow version: python3 -c "import tensorflow as tf; print(tf.version)" 2.9.2
Is there a way to resolve this/ can you change the requirements so this package will work with tensorflow-macos?