【问题标题】:Different behavior between Jupyter kernel and PythonJupyter 内核和 Python 之间的不同行为
【发布时间】:2018-01-08 09:18:23
【问题描述】:

我一直在本地使用 Jupyter 笔记本,最近将其迁移到位于远程服务器上的 Ubuntu Linux VM。我已经在远程服务器上成功安装了 Python 和 Jupyter,并且正在访问它via SSH portforwarding。我已经能够成功运行其他脚本和文件,但是脚本一直以一种非常奇怪的方式停止。

我有一个大型 pandas DataFrame(40k 行 x 60 列),我正在对其进行预处理以准备并行操作,因此我使用 pandas .groupby 对 DataFrame 进行切片,然后将每个切片与使用itertools.product 的分类变量,下面是模拟示例

import itertools as itt
import pandas as pd
import numpy as np

# Mocked Data
alphabet = 'abcdefghijklmnopqrstuvwxyz'
dates = [pd.to_datetime('{}-{}-1'.format(y,m+1)) + pd.tseries.offsets.MonthEnd(0) for y, m in itt.product(
    range(2007, 2018),
    range(0,12)
)]
dataframe = pd.DataFrame(
    index=range(0,40000),
    columns=[''.join(t) for t in list(itt.combinations(alphabet,2))[0:60]])
dataframe['ab'] = np.random.choice(dates, 40000, True)
dataframe['ac'] = np.random.choice(list(alphabet[0:6]), 40000, True)

numeric_cols = dataframe.columns[~dataframe.columns.isin(['ab', 'ac'])]
dataframe.loc[:, numeric_cols] = np.random.random((len(dataframe.index), len(numeric_cols)))

FACTORS = set(alphabet[0:15])

# Halts here! Does not finish, but no errors.
preproc = list(itt.product(
    FACTORS,
    dataframe.groupby(['ab', 'ac'])
))

不知何故,当我在 Jupyter 中作为单个单元执行此操作时,它根本无法完成,只是在操作中停止。系统监视器显示特定 Python 进程使用 100% 的 CPU,但未完成。

我不认为这是由于处理能力/内存不足,或代码问题,因为我已经能够在本地机器上的 Jupyter 以及 python 中运行此操作(即.py文件)在 VM 上具有相同的内核。

感谢任何帮助/指导!

远程机器的规格和软件包的相关版本如下:

OS:
Linux cooVM 4.10.0-42-generic #46~16.04.1 -Ubuntu SMP x86_64 GNU/Linux

Hardware:
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
CPU(s):                8
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 44
Model name:            Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz
Stepping:              2
CPU MHz:               2400.085
Hypervisor vendor:     VMware
RAM:                   16GB

Python 3.5.2

Pip 包:

Package                       Version  
----------------------------- ---------  
ipykernel                     4.7.0    
ipython                       6.2.1    
ipython-genutils              0.2.0    
ipywidgets                    7.1.0     
jupyter                       1.0.0    
jupyter-client                5.2.0    
jupyter-console               5.2.0    
jupyter-core                  4.4.0        
notebook                      5.2.2    
numpy                         1.13.3   
pandas                        0.22.0     
pip                           9.0.1       
python-apt                    1.1.0b1  
python-dateutil               2.6.1    
python-debian                 0.1.27   
python-systemd                231       
widgetsnbextension            3.1.0  

【问题讨论】:

    标签: python linux ipython jupyter-notebook jupyter


    【解决方案1】:

    这是 Jupyter 的一个持续问题,仅在 Windows 计算机上发生。 Github 问题在此处跟踪:

    https://github.com/jupyter/notebook/issues/714

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-25
      • 2023-01-27
      • 2017-05-17
      • 2017-10-30
      相关资源
      最近更新 更多