-
Notifications
You must be signed in to change notification settings - Fork 74.4k
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
Python 3.7 compatibility #20517
Comments
Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. |
Updated the original post as requested. |
@homofortis You could use this meanwhile with Homebrew to downgrade your Python version.
|
@activatedgeek Pardon me, but I fail to see how downgrading answers the the OP question regarding the timeline of making Tensorflow compatible with Python 3.7 (released almost a month ago). |
@homofortis Apologies. I probably missed a few words in there and thought that your main objective was to compile from source. A lot of searches were leading to this issue, I thought it would be good for everyone who's looking to just run Tensorflow. |
As I see from description diagnostics is not related to tensorflow compatibility with Python-3.7 but with usage of too old Cython and currently exactly this issue is not reproducing because Cython mentioned in Bazel workspace is new enough. On the other hand there are at least 2 Python-3.7 compatibility issues:
|
FWIW, I just built (not tested yet) tensorflow 1.9 with MKL on Windows for Python 3.7 using VS2017 and the following patch: diff --git a/tensorflow/c/eager/c_api.h b/tensorflow/c/eager/c_api.h
index 1862af3ce2..093b97110f 100644
--- a/tensorflow/c/eager/c_api.h
+++ b/tensorflow/c/eager/c_api.h
@@ -76,7 +76,7 @@ typedef enum TFE_ContextDevicePlacementPolicy {
// Sets the default execution mode (sync/async). Note that this can be
// overridden per thread using TFE_ContextSetAsyncForThread.
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetAsync(TFE_ContextOptions*,
- unsigned char async);
+ unsigned char is_async);
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetDevicePlacementPolicy(
TFE_ContextOptions*, TFE_ContextDevicePlacementPolicy);
@@ -125,7 +125,7 @@ TFE_ContextGetDevicePlacementPolicy(TFE_Context*);
// Overrides the execution mode (sync/async) for the current thread.
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context*,
- unsigned char async,
+ unsigned char is_async,
TF_Status* status);
// Causes the calling thread to block till all ops dispatched in async mode
diff --git a/tensorflow/core/platform/windows/port.cc b/tensorflow/core/platform/windows/port.cc
index 174f41a993..b06434620e 100644
--- a/tensorflow/core/platform/windows/port.cc
+++ b/tensorflow/core/platform/windows/port.cc
@@ -57,6 +57,11 @@ int NumSchedulableCPUs() {
return system_info.dwNumberOfProcessors;
}
+int NumHyperthreadsPerCore() {
+ static const int ht_per_core = tensorflow::port::CPUIDNumSMT();
+ return (ht_per_core > 0) ? ht_per_core : 1;
+}
+
void* AlignedMalloc(size_t size, int minimum_alignment) {
#ifdef TENSORFLOW_USE_JEMALLOC
void* ptr = NULL;
diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc
index 6c9481c3af..13edbb07db 100644
--- a/tensorflow/python/eager/pywrap_tfe_src.cc
+++ b/tensorflow/python/eager/pywrap_tfe_src.cc
@@ -813,7 +813,7 @@ char* TFE_GetPythonString(PyObject* o) {
}
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(o)) {
- return PyUnicode_AsUTF8(o);
+ return (char *)PyUnicode_AsUTF8(o);
}
#endif
return nullptr;
diff --git a/tensorflow/python/lib/core/ndarray_tensor.cc b/tensorflow/python/lib/core/ndarray_tensor.cc
index 9df38d464c..4150fbfdd4 100644
--- a/tensorflow/python/lib/core/ndarray_tensor.cc
+++ b/tensorflow/python/lib/core/ndarray_tensor.cc
@@ -154,7 +154,7 @@ Status PyBytesArrayMap(PyArrayObject* array, F f) {
if (PyUnicode_Check(item.get())) {
#if PY_VERSION_HEX >= 0x03030000
// Accept unicode by converting to UTF-8 bytes.
- ptr = PyUnicode_AsUTF8AndSize(item.get(), &len);
+ ptr = (char *)PyUnicode_AsUTF8AndSize(item.get(), &len);
if (!ptr) {
return errors::Internal("Unable to get element as UTF-8.");
}
diff --git a/tensorflow/python/lib/core/py_func.cc b/tensorflow/python/lib/core/py_func.cc
index 30c1a9c759..231a66de59 100644
--- a/tensorflow/python/lib/core/py_func.cc
+++ b/tensorflow/python/lib/core/py_func.cc
@@ -322,7 +322,7 @@ Status ConvertNdarrayToTensor(PyObject* obj, Tensor* ret) {
Py_ssize_t el_size;
if (PyBytes_AsStringAndSize(input_data[i], &el, &el_size) == -1) {
#if PY_MAJOR_VERSION >= 3
- el = PyUnicode_AsUTF8AndSize(input_data[i], &el_size);
+ el = (char *)PyUnicode_AsUTF8AndSize(input_data[i], &el_size);
#else
el = nullptr;
if (PyUnicode_Check(input_data[i])) { |
I prefer to add the |
@asimshankar says that he's been reviewing and sending PRs on this topic. I'll assign him. |
…char*" instead of a "char*". (See https://docs.python.org/3/whatsnew/3.7.html#c-api-changes) There are additional changes needed for Python 3.7 compatibility, this change just pulls out one of them (and subsumes a related attempt in #21202 and #20766) Helps with #20517 PiperOrigin-RevId: 207008013
I'm facing similar issues when building from source too, using python 3.7 in Arch Linux.
My system configuration is: |
Tensorflow 1.13-rc0 has been released (https://github.com/tensorflow/tensorflow/releases/tag/v1.13.0-rc0), however there is no Python 3.7 build on PyPI (https://pypi.org/project/tensorflow/1.13.0rc0/#files). Will Tensorflow 1.13 be released for Python 3.7 officially? |
We are aiming to try and have Windows and Ubuntu python binaries by rc2 or the official. |
Any news about Mac support? I'm stuck on Mac for now.
…On Jan 24, 2019, 6:55 AM -0600, Amit Patankar ***@***.***>, wrote:
We are aiming to try and have Windows and Ubuntu python binaries by rc2 or the official.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
We now have a |
To anyone else coming to this thread, the above mentioned tf-nightly packages are good. Install them with |
I can't seem to be able to install it. Any simple troubleshooting steps ? |
@MagixInTheAir I'm closing this issue since it's just about general Python 3.7 support. Please reopen a new issue with logs and more information about your setup if you're still having issues. |
Python 3.7 compatibility seems fixed in 1.13, see eg. tensorflow#20517 and tensorflow#17022.
Tensorflow 1.13.1 now supports Python 3.7. |
https://pypi.org/project/tensorflow/#files There are cp37 releases for tensorflow==1.13.1. There may be something wrong in your environment. |
I am using 3.7.2 and I have the same issue, the version/tags reported for 1.31.1 are the following: {('cp37', 'cp37m', 'manylinux1_x86_64')} while my 3.7.2 supports the following: [('cp37', 'cp37m', 'linux_x86_64'), ('cp37', 'abi3', 'linux_x86_64'), ('cp37', 'none', 'linux_x86_64'), ('cp36', 'abi3', 'linux_x86_64'), ('cp35', 'abi3', 'linux_x86_64'), ('cp34', 'abi3', 'linux_x86_64'), ('cp33', 'abi3', 'linux_x86_64'), ('cp32', 'abi3', 'linux_x86_64'), ('py3', 'none', 'linux_x86_64'), ('cp37', 'none', 'any'), ('cp3', 'none', 'any'), ('py37', 'none', 'any'), ('py3', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')] (from pep425tags.get_supported()) so I believe the issue is just that it should be I have a clean python build from source with almost default parameters. |
@dellelce you may be using a very old version of pip?
gives me manylinux tags. |
I just checked and the problem is with the alpine build, my build (dellelce/py-base) and official docker alpine image (python:alpine) have the issue while an image built on debian (python:latest) works fine. All have latest pip and 3.7.3 or 3.7.2... |
I’m pretty sure that Alpine is not included in the many Linux that manylinux supports. |
@ppwwyyxx should we have another ticket for supporting non-glibc linux distributions? PEP 571/PEP 513 ("manylinux") support only glibc. |
@dellelce Supporting alpine linux could be an interesting idea but may not be trivial. At the moment most of the tensorflow binaries are compiled with Ubuntu 14.04. Even some other commonly used platforms (e.g. CentOS) occasionally encountered some issues. I think alpine support is unlikely to be a priority in the short term. Opening an issue is always a good thing, as it could help gauge the need and interest from the community, and it could always be labeled as "contributions welcome". |
I'm sure developers are working hard to catch up with Python 3.7.
Is there any timeline?
pip3 install tensorflow - apparently does not work, building from source:
OS Platform and Distribution: Mac OS X 10.13.5
Python: Python 3.7.0 (Homebrew)
TensorFlow installed from: source (https://github.com/tensorflow/tensorflow.git)
TensorFlow version: TensorFlow 1.9.0-rc2
Bazel version:
CUDA/cuDNN version: None
GPU model and memory: None
Exact command to reproduce:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
The text was updated successfully, but these errors were encountered: